Skip to content

Commit 15968c9

Browse files
committed
Changed to have a dir for each benchmark
1 parent 6cc1cd0 commit 15968c9

File tree

4 files changed

+27
-42
lines changed

4 files changed

+27
-42
lines changed

base/_functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
benchmark () {
22
fw="$1"
33
url="$2"
4-
output_wrk="output/$fw.wrk.log"
5-
output="output/$fw.output"
4+
output_wrk="output/$dir_datetime/$fw.wrk.log"
5+
output="output/$dir_datetime/$fw.output"
66

77
# check out the appropriate response is reachable
88
url_status=$(bash check.sh -t "$fw")

base/hello_world.sh

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,17 @@ cd `dirname $0`
66

77
bn_name=`basename $0 .sh`
88

9-
file_time=`date +%Y-%m-%dT%H-%M-%S`
9+
cd ..
1010

11-
results_file="output/results.$bn_name.$file_time.log"
12-
check_file="output/check.$bn_name.log"
13-
error_file="output/error.$bn_name.log"
14-
url_file="output/urls.log"
11+
mkdir -p output
1512

16-
cd ..
13+
export dir_datetime=`date +%y-%m-%dT%H-%M-%S`
14+
mkdir output/$dir_datetime
1715

18-
if [ -f "$results_file" ]; then
19-
echo "moving $results_file to $results_file.old"
20-
mv "$results_file" "$results_file.old"
21-
fi
22-
23-
if [ -f "$check_file" ]; then
24-
echo "moving $check_file to $check_file.old"
25-
mv "$check_file" "$check_file.old"
26-
fi
27-
28-
if [ -f "$error_file" ]; then
29-
echo "moving $error_file to $error_file.old"
30-
mv "$error_file" "$error_file.old"
31-
fi
32-
33-
if [ -f "$url_file" ]; then
34-
echo "moving $url_file to $url_file.old"
35-
mv "$url_file" "$url_file.old"
36-
fi
16+
results_file="output/$dir_datetime/results.log"
17+
check_file="output/$dir_datetime/check.log"
18+
error_file="output/$dir_datetime/error.log"
19+
url_file="output/$dir_datetime/urls.log"
3720

3821
phpc=`curl -s "$base/libs/php_config.php"`
3922
echo "/------- PHP Config -------/"

index.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
$dataTime = [];
1313
$dataFile = [];
1414

15-
$resultsFiles = glob("./output/results.hello_world.*.log");
15+
$resultsDirs = glob("./output/*", GLOB_ONLYDIR);
1616

17-
rsort($resultsFiles);
17+
rsort($resultsDirs);
18+
19+
$resultsDir = @$resultsDirs[0].'/results.log';
1820

19-
$resultsFile = @$resultsFiles[0];
20-
21-
if (file_exists($resultsFile)) {
21+
if (file_exists($resultsDir)) {
2222
Parse_Results: {
2323
require __DIR__ . '/libs/parse_results.php';
24-
$results = parse_results($resultsFile);
24+
$results = parse_results($resultsDir);
2525
}
2626

2727
foreach ($results as $fw => $params) {
@@ -48,18 +48,18 @@
4848
<h1>PHP Frameworks Bench</h1>
4949

5050
<?php
51-
if (!file_exists($resultsFile)) {
51+
if (!file_exists($resultsDir)) {
5252
?>
53-
<b>output/results.hello_world.log</b> not found!
53+
<b>Results</b> not found!
5454
<ul style="list-style-type:decimal">
5555
<li>Run <b>bash setup.sh</b></li>
5656
<li>Run <b>bash check.sh</b></li>
5757
<li>Run <b>bash benchmark.sh</b></li>
5858
</ul>
5959
<?php
6060
} else {
61-
if (preg_match("/results.hello_world.(\S+).log/", @$resultsFile, $match)) {
62-
echo "<h4>" . $match[1] . "</h4>";
61+
if (preg_match("/output\/(\S+)\/results.log/", @$resultsDir, $match)) {
62+
echo "<h4>" . @$match[1] . "</h4>";
6363
}
6464
?>
6565
<br>

libs/show_results_table.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
require './libs/parse_results.php';
44
require './libs/build_table.php';
55

6-
$files = glob("./output/results.hello_world.*.log");
6+
$results = glob("./output/*", GLOB_ONLYDIR);
77

8-
rsort($files);
8+
rsort($results);
99

10-
echo @$files[0].PHP_EOL;
10+
if (preg_match("/output\/(\S+)/", @$results[0], $match)) {
11+
echo "Results: ".@$match[1].PHP_EOL;
12+
}
1113

12-
$results = parse_results(@$files[0]);
14+
$pr = parse_results(@$results[0].'/results.log');
1315

14-
echo build_table($results);
16+
echo build_table($pr);

0 commit comments

Comments
 (0)