Skip to content

Commit e2c81eb

Browse files
committed
Fixes with multiple results
1 parent 8d45efd commit e2c81eb

File tree

2 files changed

+84
-14
lines changed

2 files changed

+84
-14
lines changed

index.php

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,49 @@
44
<head>
55
<meta charset="UTF-8">
66
<title>PHP Frameworks Bench</title>
7+
</head>
8+
9+
<body style="max-width: 1200px; margin:0 auto; padding: 15px 30px">
10+
<h1>PHP Frameworks Bench</h1>
11+
712
<script>
813
<?php
14+
ini_set('display_errors', '1');
15+
ini_set('display_startup_errors', '1');
16+
error_reporting(E_ALL);
17+
18+
$target = $_GET['t'] ?? null;
19+
920
$dataLabels = [];
1021
$dataRPS = [];
1122
$dataMemory = [];
1223
$dataTime = [];
1324
$dataFile = [];
1425

26+
$dataCompRPS = [];
27+
$dataCompMemory = [];
28+
29+
$data = [];
30+
1531
$resultsDirs = glob("./output/*", GLOB_ONLYDIR);
1632

1733
rsort($resultsDirs);
18-
19-
$resultsDir = @$resultsDirs[0].'/results.log';
34+
35+
$resultsDir = @$resultsDirs[0] ;
36+
37+
if ($target!==null && file_exists('./output/' . $target)) {
38+
$resultsDir = './output/' . $target;
39+
}
40+
41+
$resultsDatetime = "";
42+
if (preg_match("/output\/(\S+)/", @$resultsDir, $match)) {
43+
$resultsDatetime = @$match[1];
44+
}
2045

2146
if (file_exists($resultsDir)) {
2247
Parse_Results: {
2348
require __DIR__ . '/libs/parse_results.php';
24-
$results = parse_results($resultsDir);
49+
$results = parse_results($resultsDir . '/results.log');
2550
}
2651

2752
foreach ($results as $fw => $params) {
@@ -30,6 +55,17 @@
3055
$dataMemory[] = $params['memory'];
3156
$dataTime[] = $params['time'];
3257
$dataFile[] = $params['file'];
58+
59+
if (empty($resultsDirs[1]))
60+
continue;
61+
62+
if (!empty($results2[$fw])) {
63+
$dataCompRPS[] = $results2[$fw]['rps'];
64+
$dataCompMemory[] = $results2[$fw]['memory'];
65+
} else {
66+
$dataCompRPS[] = 0;
67+
$dataCompMemory[] = 0;
68+
}
3369
}
3470
}
3571

@@ -39,13 +75,11 @@
3975
const dataMemory = [" . implode(",", $dataMemory) . "];
4076
const dataTime = [" . implode(",", $dataTime) . "];
4177
const dataFile = [" . implode(",", $dataFile) . "];
78+
79+
const resultsDatetime = '$resultsDatetime';
4280
";
4381
?>
4482
</script>
45-
</head>
46-
47-
<body style="max-width: 1200px; margin:0 auto; padding: 15px 30px">
48-
<h1>PHP Frameworks Bench</h1>
4983

5084
<?php
5185
if (!file_exists($resultsDir)) {
@@ -58,8 +92,12 @@
5892
</ul>
5993
<?php
6094
} else {
61-
if (preg_match("/output\/(\S+)\/results.log/", @$resultsDir, $match)) {
62-
echo "<h4>" . @$match[1] . "</h4>";
95+
echo "<h4>" . @$match[1] . "</h4>";
96+
97+
foreach ($resultsDirs as $res) {
98+
if (preg_match("/output\/(\S+)/", @$res, $match)) {
99+
echo "<a href='index.php?t=" . @$match[1] . "'>" . $match[1] . "</a> | ";
100+
}
63101
}
64102
?>
65103
<br>
@@ -77,7 +115,7 @@
77115

78116
<ul>
79117
<?php
80-
$urls = file(__DIR__ . '/output/urls.log');
118+
$urls = file($resultsDir . '/urls.log');
81119
foreach ($urls as $url) {
82120
$url_array = explode('/', $url);
83121
// to make it shorter

libs/app.js

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,19 @@ var fileChart = document.getElementById("fileChart");
4040

4141
new Chart(rpsChart, {
4242
type: "bar",
43+
options: {
44+
plugins: {
45+
title: {
46+
display: true,
47+
text: 'Requests Per Second (RPS)'
48+
},
49+
}
50+
},
4351
data: {
4452
labels: dataLabels,
4553
datasets: [
4654
{
47-
label: "Requests Per Second (RPS)",
55+
label: resultsDatetime,
4856
data: dataRPS,
4957
backgroundColor: COLORS,
5058
},
@@ -54,11 +62,19 @@ new Chart(rpsChart, {
5462

5563
new Chart(memoryChart, {
5664
type: "bar",
65+
options: {
66+
plugins: {
67+
title: {
68+
display: true,
69+
text: 'Memory Peak (MB)'
70+
},
71+
}
72+
},
5773
data: {
5874
labels: dataLabels,
5975
datasets: [
6076
{
61-
label: "Memory Peak (MB)",
77+
label: resultsDatetime,
6278
data: dataMemory,
6379
backgroundColor: COLORS,
6480
},
@@ -68,11 +84,19 @@ new Chart(memoryChart, {
6884

6985
new Chart(timeChart, {
7086
type: "bar",
87+
options: {
88+
plugins: {
89+
title: {
90+
display: true,
91+
text: 'Execution Time (ms)'
92+
},
93+
}
94+
},
7195
data: {
7296
labels: dataLabels,
7397
datasets: [
7498
{
75-
label: "Execution Time (ms)",
99+
label: resultsDatetime,
76100
data: dataTime,
77101
backgroundColor: COLORS,
78102
},
@@ -82,11 +106,19 @@ new Chart(timeChart, {
82106

83107
new Chart(fileChart, {
84108
type: "bar",
109+
options: {
110+
plugins: {
111+
title: {
112+
display: true,
113+
text: 'Included Files'
114+
},
115+
}
116+
},
85117
data: {
86118
labels: dataLabels,
87119
datasets: [
88120
{
89-
label: "Included Files",
121+
label: resultsDatetime,
90122
data: dataFile,
91123
backgroundColor: COLORS,
92124
},

0 commit comments

Comments
 (0)