[phc-internals] [phc commit] r1188 - trunk/misc
codesite-noreply at google.com
codesite-noreply at google.com
Wed Apr 23 22:22:17 IST 2008
Author: paul.biggar
Date: Wed Apr 23 14:21:16 2008
New Revision: 1188
Modified:
trunk/misc/bench_compare
Log:
The old barcharts generated by bench_compare were very poor and
difficult to read. This uses a preprocessing script for gnuplot which
makes barcharts easy, removing a lot of the calculations and errors
from my implementation.
Modified: trunk/misc/bench_compare
==============================================================================
--- trunk/misc/bench_compare (original)
+++ trunk/misc/bench_compare Wed Apr 23 14:21:16 2008
@@ -7,6 +7,8 @@
# times. It will then calculate the speedup, and plot them on a single graph,
# NAME.plot.
+# bargraph.pl is available from http://www.burningcutlery.com/derek/bargraph/
+
if (count ($argv) < 1)
{
print ("usage: bench_compare php_NAME\n
@@ -35,6 +37,10 @@
if (!preg_match ("/^\w+\s+[0-9\.]+$/", $res))
die ("bad line: '$res'");
list ($name, $time) = split ("[ ]+", $res);
+
+ if ($name == "Total") // ignore total
+ continue;
+
$results [$name] = $time;
}
return $results;
@@ -58,100 +64,28 @@
$phc_results = parse ("$dirname/phc_$title.txt");
# work out the speedups
- foreach ($php_results as $name => $php_time)
- {
- $phc_time = $phc_results[$name];
- if ($php_time > $phc_time) # php is slower
- $speedups[$name] = ($php_time / $phc_time) - 1;
- else
- $speedups[$name] = (($phc_time / $php_time) - 1) * -1;
- }
-
- # add an average
- $total = array_sum (array_values ($speedups));
- $speedups["average"] = $total / count ($speedups);
-
-
-
- # Make the gnuplot file, we create the entire file in a single file.
- # Data is in a single column, with the names in an xtics
- # command. We plot from a zero centered bar graph.
-
-
- # find the range
- $maxxrange = count ($speedups) - 0.5;
-
- # add labels
- $labels = "";
- foreach (array_keys ($speedups) as $i => $name)
- {
- if ($speedups[$name] < 0)
- $labels .= "set label \"$name\" at $i,0.2 rotate left\n";
- else
- $labels .= "set label \"$name\" at $i,-0.2 rotate right\n";
- }
-
- # format the data
- foreach (array_values ($speedups) as $i => $float)
- $data .= "$i $float\n";
-
- # create the y tics (3x 2x 1x 2x 3x etc)
- $minyrange = array_reduce (
- array_values ($speedups),
- create_function ('$x, $y', 'return min ((float)($x), (float)($y));'));
- $intminyrange = (int)($minyrange) - 1;
-
- $maxyrange = array_reduce (
- array_values ($speedups),
- create_function ('$x, $y', 'return max ((float)($x), (float)($y));'));
- $intmaxyrange = (int)($maxyrange) + 1;
-
- $ytics = " (";
- for ($i = $intminyrange; $i < 0; $i++)
+ foreach ($php_results as $name => $php)
{
- $times = -$i + 1;
- $ytics .= "\"{$times}x\" $i, ";
+ $phc = $phc_results[$name];
+ $time = ($php / $phc);
+ $speedups .= "$name $time\n";
}
- $ytics .= "\"\" 0, ";
-
- for (++$i; $i <= $intmaxyrange; $i++)
- {
- $times = $i + 1;
- $ytics .= "\"{$times}x\" $i, ";
- }
- $ytics .= "\"\" $i)";
+
+ $string = <<<BARGRAPH
+=base1
+yformat=%g
+ylabel=Speed-up of compiled benchmark
+=arithmean
- // create a bit more space
- $minyrange *= 1.05;
- $maxyrange *= 1.05;
-
-
- $string = <<<GNUPLOT
-set term postscript eps enhanced
-set output "results/$title.eps"
-set nokey
-$labels
-set yrange [$minyrange:$maxyrange]
-set noxtics
-set ytics $ytics rotate
-set y2tics $ytics rotate
-set y2tics out
-set ytics out
-set label "PHP faster" at $maxxrange+0.5,-0.2 rotate right
-set label "PHP faster" at -1.0,-0.2 rotate right
-set label "phc faster" at $maxxrange+0.5, 0.2 rotate left
-set label "phc faster" at -1.0, 0.2 rotate left
-set xzeroaxis 1
-plot "-" using 1:2:(0.7) with boxes fs solid 0.25
-$data
-end
+$speedups
-GNUPLOT;
+
+BARGRAPH;
file_put_contents ("results/$title.plot", $string);
- `gnuplot results/$title.plot`;
+ echo `bargraph.pl results/$title.plot > results/title.eps`;
?>
More information about the phc-internals
mailing list