Skip to content

Commit 56594fc

Browse files
committed
Add included file count to results
1 parent 2a64d58 commit 56594fc

File tree

4 files changed

+57
-80
lines changed

4 files changed

+57
-80
lines changed

benchmarks/_functions.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ benchmark ()
1010
curl "$url" > "$output"
1111

1212
rps=`grep "Requests per second:" "$ab_log" | cut -f 7 -d " "`
13-
m=`tail -1 "$output" | cut -f 1 -d ':'`
14-
t=`tail -1 "$output" | cut -f 2 -d ':'`
15-
echo "$fw: $rps: $m: $t" >> "$results_file"
13+
memory=`tail -1 "$output" | cut -f 1 -d ':'`
14+
time=`tail -1 "$output" | cut -f 2 -d ':'`
15+
file=`tail -1 "$output" | cut -f 3 -d ':'`
16+
echo "$fw: $rps: $memory: $time: $file" >> "$results_file"
1617

1718
echo "$fw" >> "$check_file"
1819
grep "Document Length:" "$ab_log" >> "$check_file"

index.php

Lines changed: 45 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,86 +5,56 @@
55

66
$results = parse_results(__DIR__ . '/output/results.hello_world.log');
77

8-
$barColors = array(
9-
'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen',
10-
'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid',
11-
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray',
12-
'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen',
13-
'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid',
14-
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray',
15-
);
16-
17-
$graphWidth = 1000;
18-
$graphHeight = 400;
19-
20-
// RPS Benchmark
21-
$data[] = array('', 'rps', array('role' => 'style')); // header
22-
23-
$colors = $barColors;
24-
foreach ($results as $fw => $result) {
25-
$data[] = array($fw, $result['rps'], array_shift($colors));
8+
function makeGraph($id, $title, $hAxis_title)
9+
{
10+
global $results;
11+
12+
$barColors = array(
13+
'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen',
14+
'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid',
15+
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray',
16+
'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen',
17+
'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid',
18+
'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray',
19+
);
20+
$graphWidth = 1000;
21+
$graphHeight = 400;
22+
23+
$data = array();
24+
$data[] = array('', $id, array('role' => 'style')); // header
25+
26+
$colors = $barColors;
27+
foreach ($results as $fw => $result) {
28+
$data[] = array($fw, $result[$id], array_shift($colors));
29+
}
30+
//var_dump($data); exit;
31+
32+
$options = array(
33+
'title' => $title,
34+
'titleTextStyle' => array('fontSize' => 16),
35+
'hAxis' => array('title' => $hAxis_title,
36+
'titleTextStyle' => array('bold' => true)),
37+
'vAxis' => array('minValue' => 0, 'maxValue' => 0.01),
38+
'width' => $graphWidth,
39+
'height' => $graphHeight,
40+
'bar' => array('groupWidth' => '90%'),
41+
'legend' => array('position' => 'none')
42+
);
43+
$type = 'ColumnChart';
44+
return makeChartParts($data, $options, $type);
2645
}
27-
//var_dump($data); exit;
2846

29-
$options = array(
30-
'title' => 'Throughput',
31-
'titleTextStyle' => array('fontSize' => 16),
32-
'hAxis' => array('title' => 'requests per second',
33-
'titleTextStyle' => array('bold' => true)),
34-
'vAxis' => array('minValue' => 0, 'maxValue' => 0.01),
35-
'width' => $graphWidth,
36-
'height' => $graphHeight,
37-
'bar' => array('groupWidth' => '90%'),
38-
'legend' => array('position' => 'none')
39-
);
40-
$type = 'ColumnChart';
41-
list($chart_rpm, $div_rpm) = makeChartParts($data, $options, $type);
47+
// RPS Benchmark
48+
list($chart_rpm, $div_rpm) = makeGraph('rps', 'Throughput', 'requests per second');
4249

4350
// Memory Benchmark
44-
$data = array();
45-
$data[] = array('', 'memory', array('role' => 'style')); // header
46-
47-
$colors = $barColors;
48-
foreach ($results as $fw => $result) {
49-
$data[] = array($fw, $result['memory'], array_shift($colors));
50-
}
51-
52-
$options = array(
53-
'title' => 'Memory',
54-
'titleTextStyle' => array('fontSize' => 16),
55-
'hAxis' => array('title' => 'peak memory (MB)',
56-
'titleTextStyle' => array('bold' => true)),
57-
'vAxis' => array('minValue' => 0, 'maxValue' => 1),
58-
'width' => $graphWidth,
59-
'height' => $graphHeight,
60-
'bar' => array('groupWidth' => '90%'),
61-
'legend' => array('position' => 'none')
62-
);
63-
$type = 'ColumnChart';
64-
list($chart_mem, $div_mem) = makeChartParts($data, $options, $type);
51+
list($chart_mem, $div_mem) = makeGraph('memory', 'Memory', 'peak memory (MB)');
6552

6653
// Exec Time Benchmark
67-
$data = array();
68-
$data[] = array('', 'time', array('role' => 'style')); // header
69-
70-
$colors = $barColors;
71-
foreach ($results as $fw => $result) {
72-
$data[] = array($fw, $result['time'], array_shift($colors));
73-
}
54+
list($chart_time, $div_time) = makeGraph('time', 'Exec Time', 'ms');
7455

75-
$options = array(
76-
'title' => 'Exec Time',
77-
'titleTextStyle' => array('fontSize' => 16),
78-
'hAxis' => array('title' => 'ms',
79-
'titleTextStyle' => array('bold' => true)),
80-
'vAxis' => array('minValue' => 0, 'maxValue' => 1),
81-
'width' => $graphWidth,
82-
'height' => $graphHeight,
83-
'bar' => array('groupWidth' => '90%'),
84-
'legend' => array('position' => 'none')
85-
);
86-
$type = 'ColumnChart';
87-
list($chart_time, $div_time) = makeChartParts($data, $options, $type);
56+
// Included Files
57+
list($chart_file, $div_file) = makeGraph('file', 'Included Files', 'count');
8858
?>
8959
<!DOCTYPE html>
9060
<html lang="en">
@@ -94,7 +64,7 @@
9464
<script src="https://www.google.com/jsapi"></script>
9565
<script>
9666
<?php
97-
echo $chart_rpm, $chart_mem, $chart_time;
67+
echo $chart_rpm, $chart_mem, $chart_time, $chart_file;
9868
?>
9969
</script>
10070
</head>
@@ -103,7 +73,7 @@
10373
<h2>Hello World Benchmark</h2>
10474
<div>
10575
<?php
106-
echo $div_rpm, $div_mem, $div_time;
76+
echo $div_rpm, $div_mem, $div_time, $div_file;
10777
?>
10878
</div>
10979

libs/output_data.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22

33
printf(
4-
"\n%' 8d:%f",
4+
"\n%' 8d:%f:%d",
55
memory_get_peak_usage(true),
6-
microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']
6+
microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'],
7+
count(get_included_files())
78
);

libs/parse_results.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,34 @@ function parse_results($file)
88
$min_rps = INF;
99
$min_memory = INF;
1010
$min_time = INF;
11+
$min_file = INF;
1112

1213
foreach ($lines as $line) {
1314
$column = explode(':', $line);
1415
$fw = $column[0];
1516
$rps = (float) trim($column[1]);
1617
$memory = (float) trim($column[2])/1024/1024;
1718
$time = (float) trim($column[3])*1000;
19+
$file = (int) trim($column[4]);
1820

1921
$min_rps = min($min_rps, $rps);
2022
$min_memory = min($min_memory, $memory);
2123
$min_time = min($min_time, $time);
24+
$min_file = min($min_file, $file);
2225

2326
$results[$fw] = [
2427
'rps' => $rps,
2528
'memory' => $memory,
2629
'time' => $time,
30+
'file' => $file,
2731
];
2832
}
2933

3034
foreach ($results as $fw => $data) {
3135
$results[$fw]['rps_relative'] = $data['rps'] / $min_rps;
3236
$results[$fw]['memory_relative'] = $data['memory'] / $min_memory;
3337
$results[$fw]['time_relative'] = $data['time'] / $min_time;
38+
$results[$fw]['file_relative'] = $data['file'] / $min_file;
3439
}
3540
// var_dump($results);
3641

0 commit comments

Comments
 (0)