-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpie.php
More file actions
executable file
·118 lines (100 loc) · 4.43 KB
/
pie.php
File metadata and controls
executable file
·118 lines (100 loc) · 4.43 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
<?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';
$summary = DB::getAllArray( "SELECT template_engine AS name,
avg(execution_time) AS execution_time,
avg(memory) AS memory
FROM template_benchmark
WHERE test=:test
GROUP BY template_engine
ORDER BY template_engine",
array(':test'=>$test)
);
$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,
avg(memory) 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' );
$color_sel = "colors:[";
$nc = sizeof($color);
$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 .= "],";
$tot = 0;
foreach( $summary as $name => $res )
$tot += round($res[$type]);
$pie = array();
foreach( $summary as $name => $res ){
if( isset( $template_show[$res['name']] ) ){
if( $type=='memory')
$pie[$res['name']] = round( $res[$type] / 1024 );
else
$pie[$res['name']] = round( $res[$type] );
}
}
$html = "data.addColumn('number', 'speed');";
$html .= "data.addRows(".(count($summary)).");\n";
$i=0;
foreach( $pie as $name => $ex ){
$html .= "data.setValue($i, 0,'$name');";
$html .= "data.setValue($i, 1, $ex);";
$i++;
}
?>
<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=='memory'?'Memory (KB)':'Execution Time (µs)'; ?>' );
<?php echo $html; ?>
var chart = new google.visualization.PieChart(document.getElementById('pie_chart'));
chart.draw(data, {width: 430, height: 350, <?echo $color_sel; ?> is3D:true, title: '<?php echo $type; ?>'});
}
</script>
</head>
<body>
<div id="pie_chart"></div>
</body>
</html>