From b3866c2617d4ef9237ab379a795c8ed9cfd4fc21 Mon Sep 17 00:00:00 2001 From: Mohammad Yaaghubi Date: Fri, 11 Aug 2023 14:45:43 +0330 Subject: [PATCH] Add comparison between last two results on table --- benchmark.sh | 2 +- libs/build_table.php | 34 +++++++++++++++++++++++++--------- libs/show_results_table.php | 15 ++++++++++----- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/benchmark.sh b/benchmark.sh index 2cb281e..1001f9f 100644 --- a/benchmark.sh +++ b/benchmark.sh @@ -85,5 +85,5 @@ done if [ "$init_benchmark" = true ]; then sh ./base/hello_world.sh echo '' - php ./libs/show_results_table.php + bash results.sh fi \ No newline at end of file diff --git a/libs/build_table.php b/libs/build_table.php index 79939f7..21858a7 100644 --- a/libs/build_table.php +++ b/libs/build_table.php @@ -1,6 +1,6 @@ $result) { + + foreach ($res1 as $fw => $result) { + $comp['rps'] = '(-)'; + $comp['memory'] = '(-)'; + if (!empty($res2[$fw])) { + $comp['rps'] = '(' . culc_percentage($result['rps'], $res2[$fw]['rps']) . '%)'; + $comp['memory'] = '(' . culc_percentage($result['memory'], $res2[$fw]['memory']) . '%)'; + } + $table .= sprintf( "|%-19s|%25s|%14s|%11s|%14s|\n", $fw, - number_format($result['rps'], 2), + number_format($result['rps'], 2) . ' ' . @$comp['rps'], number_format($result['rps_relative'], 1), - number_format($result['memory'], 2), + number_format($result['memory'], 2) . ' ' . @$comp['memory'], number_format($result['memory_relative'], 1) ); } return $table; } + +function culc_percentage($targetNumber, $baseNumber) +{ + $diff = $targetNumber - $baseNumber; + $percentage = ($diff / $baseNumber) * 100; + if ($percentage==0) + return 0; + return number_format($percentage, 1); +} diff --git a/libs/show_results_table.php b/libs/show_results_table.php index c722953..4098e00 100755 --- a/libs/show_results_table.php +++ b/libs/show_results_table.php @@ -8,14 +8,19 @@ rsort($results); $index = 0; -if (!empty($argv[1]) && $argv[1]= count($results)) { + echo build_table($pr); +} else { + $prComp = parse_results(@$results[$index+1] . '/results.log'); + echo build_table($pr, $prComp); +}