#!/usr/bin/perl
# GLanal - produce a table of results in HTML format
# for inclusion in a document
# GLanal 1.11 2007-05-22 09:08:39-04 davidsen Stable
sub proc_dir;
sub do_data_anal;
$Rev = '1.11';
$Date = localtime(time);
$State = 'Stable';
# output the header
print "
\n\n";
print " | glxgears frames per second\n";
print " | fairness - random values generated\n";
print " | \n | kernel\n";
print " | startup\n";
print " | min | max\n";
print " | avg | stddev\n";
print " | min | max\n";
print " | avg | stddev\n";
print " | Comments\n";
print "\n";
while ($dir = shift(@ARGV)) {
proc_dir($dir);
}
print "\n |
\n\n";
print "Table generated ${Date} by GLanal v${Rev} (${State})\n\n";
exit 0;
sub proc_dir
{
local ($dir) = @_;
local ($dirname, $cmntfile, @datavect, $StartupFPS);
local ($DSnum, $V_1st, $V_lo, $V_hi, $V_avg, $V_sd);
($dirname = $dir) =~ s/^D_//;
print "
\n ${dirname}\n";
# process frames per second (fps)
open(FPS, "<${dir}/gl_gears") || quit("no fps file - ${dir}");
@datavect = ();
$DSnum = 0;
while () {
push(@datavect, $1) if (m/([0-9.]+) FPS/);
if (m/^Script done/) {
# process this dataset
if ($DSnum++) {
# this is an additional set
$V_1st .= " ";
$V_lo .= " ";
$V_hi .= " ";
$V_avg .= " ";
$V_sd .= " ";
} else {
$V_1st = $V_lo = $V_hi = $V_avg = $V_sd = "";
}
# now get some analysis on the steady state data
# save the 1st value FPS as a startup case
$StartupFPS = shift(@datavect);
# do stats on the rest
@datavect = do_data_anal(@datavect);
$V_1st .= sprintf "%.1f", $StartupFPS;
$V_lo .= sprintf "%.1f", $datavect[0];
$V_hi .= sprintf "%.1f", $datavect[1];
$V_avg .= sprintf "%.1f", $datavect[2];
$V_sd .= sprintf "%.2f", $datavect[3];
# clear the vector
@datavect = ();
}
}
close FPS;
print (
" ${V_1st}\n" .
" | ${V_lo}\n | ${V_hi}\n" .
" | ${V_avg}\n | ${V_sd}\n"
);
# now process fairness info
# using the
open(FAIR, "<${dir}/gl_fairloops") || quit("no fairness file - ${dir}");
@datavect = ();
$DSnum = 0;
while () {
push(@datavect, $1) if m/ (\d+)$/;
if (m/^===/) {
# process this dataset
if ($DSnum++) {
# this is an additional set
$V_lo .= " ";
$V_hi .= " ";
$V_avg .= " ";
$V_sd .= " ";
} else {
$V_lo = $V_hi = $V_avg = $V_sd = "";
}
# add the current values to the strings
@datavect = do_data_anal(@datavect);
$V_lo .= sprintf "%d", $datavect[0];
$V_hi .= sprintf "%d", $datavect[1];
$V_avg .= sprintf "%d", $datavect[2];
$V_sd .= sprintf "%.1f", $datavect[3];
# clear the vector
@datavect = ();
}
}
close FAIR;
# now get some analysis
print (
" ${V_lo}\n | ${V_hi}\n" .
" | ${V_avg}\n | ${V_sd}\n"
);
# now look for comments
$cmntfile = "${dir}/gl_cmnt";
if (open(CMNT, "<${cmntfile}")) {
print " | ";
print $_ while ;
close CMNT;
}
# end of row
print "\n";
}
sub do_data_anal
{
local ($tot, $errtot, $avg, $min, $max, $SD, $n, $val, $err, $var, $Nval);
local (@vals) = @_;
$min = $max = $tot = $errtot = 0;
$Nval = 1 + $#vals;
for ($n = 0; $n < $Nval; ++$n) {
$val = $vals[$n];
$min = $val if $n == 0 || $val < $min;
$max = $val if $val > $max;
$tot += $val;
}
$avg = $tot / $Nval;
# standard deviation
for ($n = 0; $n < $Nval; ++$n) {
$err = $vals[$n] - $avg;
$errtot += $err * $err;
}
# variance
# Note: two statistics texts differ on using N or N-1 here...
# I used N-1, as I think I was taught, wikipedia says N
$var = $errtot / $Nval;
$SD = exp(log($var) / 2);
# return vector
# min, max, avg, std.dev
return ($min, $max, $avg, $SD);
}
| | |