-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathline.php
More file actions
executable file
·121 lines (104 loc) · 4.26 KB
/
line.php
File metadata and controls
executable file
·121 lines (104 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
require "../vendor/autoload.php";
require_once "../library/functions.php";
use Rain\DB;
DB::configure('config_dir', dirname(__DIR__) .'/config/');
DB::init();
$test = get('test')=='loop'?'loop':'assign';
$type = get('type')=='memory'?'memory':'execution_time';
$template_tested = DB::getAllArray("SELECT template_engine
FROM template_benchmark
WHERE test=:test
GROUP BY template_engine
ORDER BY template_engine",
array(':test'=>$test),
"template_engine",
"template_engine" );
$rows = DB::getAllArray( "SELECT template_engine,
n,
avg(execution_time) AS execution_time,
round(avg(memory)/1024) AS memory
FROM template_benchmark
WHERE test=:test
GROUP BY template_engine, n
ORDER BY n, template_engine",
array(':test'=>$test));
$template_show = DB::getAllArray( "SELECT template_engine,
avg(execution_time) AS execution_time
FROM template_benchmark
WHERE test=:test
GROUP BY template_engine
ORDER BY n, template_engine",
array(":test"=>$test),
"template_engine", "template_engine" );
$nrows = DB::getAllArray("SELECT n
FROM template_benchmark
WHERE test=:test
GROUP BY n",
array(':test'=>$test)
);
$color = array('#3366cc','#dc3912','#ff9900','#109618','#990099','#0099c6','#dd4477' );
$nc = sizeof($color);
$color_sel = "colors:[";
$i=0;$cs=false;
foreach( $template_tested as $template ){
if( isset($template_show[ $template ] )){
$color_sel .= $cs ? ",'".$color[$i%$nc] . "'" : "'".$color[$i%$nc] . "'" ;
$cs=true;
}
$i++;
}
$color_sel .= "],";
// create the execution time array
$tpl_array = array();
for( $i=0;$i<count($rows);$i++){
if( !isset( $tpl_array[ $rows[$i]['n'] ] ) )
$tpl_array[ $rows[$i]['n'] ][] = $rows[$i]['n'];
$tpl_array[ $rows[$i]['n'] ][] = round( $rows[$i][$type] );
}
$html = "data.addRows(".(count($nrows)).");\n";
// add column
foreach( $template_show as $tpl )
$html .= "data.addColumn('number', '$tpl');\n";
$row=0;
foreach( $tpl_array as $num => $array ){
for( $col=0;$col< count($array); $col++)
$html .= $col==0 ? 'data.setValue('.$row.','.$col.','. "'" . $num. "'" . ");\n" : 'data.setValue('.$row.','.$col.','. ( $array[$col] ) . ");\n";
$row++;
}
?>
<html>
<head>
<link href="../graph/style.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', '<?php echo $type; ?>' );
<?php echo $html; ?>
var chart = new google.visualization.LineChart(document.getElementById('line_chart'));
chart.draw(data, {lineType: "function", <?php echo $color_sel; ?> width:750, height: 300, vAxis: {maxValue: 10}} );
}
</script>
</head>
<body>
<?php
if( $type == 'memory' )
echo "Memory (KB)";
else
echo "Execution Time (μs)"
?>
<div id="line_chart"></div>
<div style="margin-left:600px;">
<?php
if( $test == 'assign' )
echo "Assigned variables";
else
echo "Array elements"
?>
</div>
</body>
</html>