Skip to content

Commit

Permalink
Changed to have a dir for each benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
myaaghubi committed Aug 11, 2023
1 parent 6cc1cd0 commit 15968c9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 42 deletions.
4 changes: 2 additions & 2 deletions base/_functions.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
benchmark () {
fw="$1"
url="$2"
output_wrk="output/$fw.wrk.log"
output="output/$fw.output"
output_wrk="output/$dir_datetime/$fw.wrk.log"
output="output/$dir_datetime/$fw.output"

# check out the appropriate response is reachable
url_status=$(bash check.sh -t "$fw")
Expand Down
33 changes: 8 additions & 25 deletions base/hello_world.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,17 @@ cd `dirname $0`

bn_name=`basename $0 .sh`

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

results_file="output/results.$bn_name.$file_time.log"
check_file="output/check.$bn_name.log"
error_file="output/error.$bn_name.log"
url_file="output/urls.log"
mkdir -p output

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

if [ -f "$results_file" ]; then
echo "moving $results_file to $results_file.old"
mv "$results_file" "$results_file.old"
fi

if [ -f "$check_file" ]; then
echo "moving $check_file to $check_file.old"
mv "$check_file" "$check_file.old"
fi

if [ -f "$error_file" ]; then
echo "moving $error_file to $error_file.old"
mv "$error_file" "$error_file.old"
fi

if [ -f "$url_file" ]; then
echo "moving $url_file to $url_file.old"
mv "$url_file" "$url_file.old"
fi
results_file="output/$dir_datetime/results.log"
check_file="output/$dir_datetime/check.log"
error_file="output/$dir_datetime/error.log"
url_file="output/$dir_datetime/urls.log"

phpc=`curl -s "$base/libs/php_config.php"`
echo "/------- PHP Config -------/"
Expand Down
20 changes: 10 additions & 10 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
$dataTime = [];
$dataFile = [];

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

rsort($resultsFiles);
rsort($resultsDirs);

$resultsDir = @$resultsDirs[0].'/results.log';

$resultsFile = @$resultsFiles[0];

if (file_exists($resultsFile)) {
if (file_exists($resultsDir)) {
Parse_Results: {
require __DIR__ . '/libs/parse_results.php';
$results = parse_results($resultsFile);
$results = parse_results($resultsDir);
}

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

<?php
if (!file_exists($resultsFile)) {
if (!file_exists($resultsDir)) {
?>
<b>output/results.hello_world.log</b> not found!
<b>Results</b> not found!
<ul style="list-style-type:decimal">
<li>Run <b>bash setup.sh</b></li>
<li>Run <b>bash check.sh</b></li>
<li>Run <b>bash benchmark.sh</b></li>
</ul>
<?php
} else {
if (preg_match("/results.hello_world.(\S+).log/", @$resultsFile, $match)) {
echo "<h4>" . $match[1] . "</h4>";
if (preg_match("/output\/(\S+)\/results.log/", @$resultsDir, $match)) {
echo "<h4>" . @$match[1] . "</h4>";
}
?>
<br>
Expand Down
12 changes: 7 additions & 5 deletions libs/show_results_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
require './libs/parse_results.php';
require './libs/build_table.php';

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

rsort($files);
rsort($results);

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

$results = parse_results(@$files[0]);
$pr = parse_results(@$results[0].'/results.log');

echo build_table($results);
echo build_table($pr);

0 comments on commit 15968c9

Please sign in to comment.