Skip to content

Commit 21b1786

Browse files
committed
Updated index.php
I put `Chartjs` instead of the old way to show the graph Fixed `clean.sh` for all frameworks to delete hidden files too
1 parent d3cc63f commit 21b1786

File tree

27 files changed

+209
-305
lines changed

27 files changed

+209
-305
lines changed

cakephp-4.3/_benchmark/clean.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
rm -rf !("_benchmark")
3+
find -path './.*' -delete
34
rm -rf _benchmark/temp
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
rm -rf !("_benchmark")
3+
find -path './.*' -delete
34
rm -rf _benchmark/temp

fastroute-1.3/_benchmark/clean.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2-
rm -rf !("_benchmark"|"Controllers"|"composer.json"|"index.php")
2+
rm -rf !("_benchmark"|"Controllers"|"composer.json"|"index.php")
3+
find -path './.*' -delete

fatfree-3.8.0/_benchmark/clean.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2-
rm -rf !("_benchmark"|"Controllers"|"composer.json"|"index.php")
2+
rm -rf !("_benchmark"|"Controllers"|"composer.json"|"index.php")
3+
find -path './.*' -delete

frameworkx-dev/_benchmark/clean.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2-
rm -rf !("_benchmark"|"Controllers"|"public"|"composer.json")
2+
rm -rf !("_benchmark"|"Controllers"|"public"|"composer.json")
3+
find -path './.*' -delete

fuelphp-1.9/_benchmark/clean.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
rm -rf !("_benchmark")
3+
find -path './.*' -delete
34
rm -rf _benchmark/temp

index.php

Lines changed: 79 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,92 @@
1-
<?php
1+
<!DOCTYPE html>
2+
<html lang="en">
23

3-
if (file_exists(__DIR__ . '/output/results.hello_world.log')) {
4-
Parse_Results: {
5-
require __DIR__ . '/libs/parse_results.php';
6-
$results = parse_results(__DIR__ . '/output/results.hello_world.log');
7-
}
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>PHP Frameworks Bench</title>
7+
<script>
8+
<?php
9+
$dataLabels = [];
10+
$dataRPS = [];
11+
$dataMemory = [];
12+
$dataTime = [];
13+
$dataFile = [];
814

9-
Load_Theme: {
10-
$theme = isset($_GET['theme']) ? $_GET['theme'] : 'default';
11-
if (! ctype_alnum($theme)) {
12-
exit('Invalid theme');
13-
}
15+
$resultsFile = __DIR__ . '/output/results.hello_world.log';
1416

15-
if ($theme === 'default') {
16-
require __DIR__ . '/libs/make_graph.php';
17-
} else {
18-
$file = __DIR__ . '/libs/' . $theme . '/make_graph.php';
19-
if (is_readable($file)) {
20-
require $file;
21-
} else {
22-
require __DIR__ . '/libs/make_graph.php';
17+
if (file_exists($resultsFile)) {
18+
Parse_Results: {
19+
require __DIR__ . '/libs/parse_results.php';
20+
$results = parse_results($resultsFile);
2321
}
24-
}
25-
}
26-
27-
// RPS Benchmark
28-
list($chart_rpm, $div_rpm) = make_graph('rps', 'Throughput', 'Requests per Second (r/s)');
29-
30-
// Memory Benchmark
31-
list($chart_mem, $div_mem) = make_graph('memory', 'Memory', 'Peak Memory (MB)');
3222

33-
// Exec Time Benchmark
34-
list($chart_time, $div_time) = make_graph('time', 'ExecTime', 'Execution Time (ms)');
35-
36-
// Included Files
37-
list($chart_file, $div_file) = make_graph('file', 'Files', 'Included Files (count)');
38-
}
23+
foreach ($results as $fw => $params) {
24+
$dataLabels[] = $fw;
25+
$dataRPS[] = $params['rps'];
26+
$dataMemory[] = $params['memory'];
27+
$dataTime[] = $params['time'];
28+
$dataFile[] = $params['file'];
29+
}
30+
}
3931

40-
?>
41-
<!DOCTYPE html>
42-
<html lang="en">
43-
<head>
44-
<meta charset="UTF-8">
45-
<title>PHP Frameworks Bench</title>
46-
<script src="https://www.google.com/jsapi"></script>
47-
<script>
48-
<?php
49-
echo $chart_rpm, $chart_mem, $chart_time, $chart_file;
50-
?>
51-
</script>
32+
echo "
33+
const dataLabels = ['".implode("','",$dataLabels)."'];
34+
const dataRPS = [".implode(",",$dataRPS)."];
35+
const dataMemory = [".implode(",",$dataMemory)."];
36+
const dataTime = [".implode(",",$dataTime)."];
37+
const dataFile = [".implode(",",$dataFile)."];
38+
";
39+
?>
40+
</script>
5241
</head>
53-
<body>
54-
<h1>PHP Frameworks Bench</h1>
55-
<h2>Hello World Benchmark</h2>
56-
<div>
57-
<?php
58-
echo @$div_rpm, @$div_mem, @$div_time, @$div_file;
5942

60-
if (!file_exists(__DIR__ . '/output/results.hello_world.log')) {
61-
echo '1. Run the \'bash setup.sh\'<br>';
62-
echo '2. Run the \'bash benchmark.sh\'';
63-
}
64-
?>
65-
</div>
43+
<body style="max-width: 1200px; margin:0 auto; padding: 15px 30px">
44+
<h1>PHP Frameworks Bench</h1>
6645

67-
<ul>
68-
<?php
69-
$url_file = __DIR__ . '/output/urls.log';
70-
if (file_exists($url_file)) {
71-
$urls = file($url_file);
72-
// sort($urls);
73-
foreach ($urls as $url) {
74-
$parts = parse_url(trim($url));
75-
$url = $parts['scheme'] . '://' . $_SERVER['HTTP_HOST'] . $parts['path'];
76-
if (isset($parts['query'])) {
77-
$url .= '?' . $parts['query'];
78-
}
79-
echo '<li><a href="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') .
80-
'">' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') .
81-
'</a></li>' . "\n";
46+
<?php
47+
if (!file_exists($resultsFile)) {
48+
?>
49+
<b>output/results.hello_world.log</b> not found!
50+
<ul style="list-style-type:decimal">
51+
<li>Run <b>bash setup.sh</b></li>
52+
<li>Run <b>bash check.sh</b></li>
53+
<li>Run <b>bash benchmark.sh</b></li>
54+
</ul>
55+
<?php
56+
} else {
57+
echo "<h4>" . date("Y/m/d H:i:s", filemtime($resultsFile)) . "</h4>";
58+
?>
59+
<br>
60+
<canvas id="rpsChart" height="120"></canvas>
61+
<br>
62+
<canvas id="memoryChart" height="120"></canvas>
63+
<br>
64+
<canvas id="timeChart" height="120"></canvas>
65+
<br>
66+
<canvas id="fileChart" height="120"></canvas>
67+
<?php
8268
}
83-
}
84-
?>
85-
</ul>
69+
?>
8670

87-
<hr>
71+
<ul>
72+
<?php
73+
$urls = file(__DIR__ . '/output/urls.log');
74+
foreach ($urls as $url) {
75+
$url_array = explode('/', $url);
76+
// to make it shorter
77+
$url_array = array_slice($url_array,4);
78+
echo "<li><a href=\"$url\">.../".implode('/', $url_array)."</a></li>";
79+
}
80+
?>
81+
</ul>
82+
<br>
83+
<hr>
8884

89-
<footer>
90-
<p style="text-align: right">This page is a part of <a href="https://github.com/myaaghubi/PHP-Frameworks-Bench">PHP-Frameworks-Bench</a>.</p>
91-
</footer>
85+
<footer>
86+
<p>This page is a part of <a href="https://github.com/myaaghubi/PHP-Frameworks-Bench">PHP-Frameworks-Bench</a>.</p>
87+
</footer>
88+
<script src="libs/chart4.3.js"></script>
89+
<script src="libs/app.js"></script>
9290
</body>
93-
</html>
91+
92+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
rm -rf !("_benchmark")
3+
find -path './.*' -delete
34
rm -rf _benchmark/temp

laravel-9.1/_benchmark/clean.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
rm -rf !("_benchmark")
3+
find -path './.*' -delete
34
rm -rf _benchmark/temp

leaf-3.0/_benchmark/clean.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
2-
rm -rf !("_benchmark"|"Controllers"|"composer.json"|"index.php")
2+
rm -rf !("_benchmark"|"Controllers"|"composer.json"|"index.php")
3+
find -path './.*' -delete

0 commit comments

Comments
 (0)