From abd6945e8e239e430a8f532d0d3c84d6fd28c861 Mon Sep 17 00:00:00 2001 From: AmiiirCom Date: Tue, 30 Jul 2024 03:40:54 +0330 Subject: [PATCH 1/2] Update benchmark.php --- benchmark.php | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/benchmark.php b/benchmark.php index 13f4893..af6ad09 100644 --- a/benchmark.php +++ b/benchmark.php @@ -181,6 +181,49 @@ function timer_diff($timeStart) return number_format(microtime(true) - $timeStart, 3); } +function grading_the_result($total){ + $grade = array(); + + preg_match('/[\d\.]+/', $total, $matches); + + $number = $matches[0]; + + if ( $number <= 0.150 ){ + $grade = array( + 'color' => '#5ec52b', + 'rating' => 'Excellent' + ); + + } elseif ( $number > 0.150 and $number <= 0.350 ){ + $grade = array( + 'color' => '#a3a71f', + 'rating' => 'Good' + ); + } elseif ( $number > 0.350 and $number <= 0.750 ){ + $grade = array( + 'color' => '#ff6c00', + 'rating' => 'Acceptable' + ); + } elseif ( $number > 0.750 and $number <= 1.0 ){ + $grade = array( + 'color' => '#cd5700', + 'rating' => 'Weak' + ); + } elseif ( $number > 1.0 and $number <= 1.5 ){ + $grade = array( + 'color' => '#fd0000', + 'rating' => 'Bad' + ); + } else { + $grade = array( + 'color' => '#900', + 'rating' => 'Awful!' + ); + } + + return $grade; +} + function print_html_result(array $data, bool $showServerName = true) { echo "\n\n"; @@ -328,7 +371,7 @@ function print_html_result(array $data, bool $showServerName = true) $result .= ''; } - $result .= 'Total' . h($data['benchmark']['total']) . ''; + $result .= 'Total' . h($data['benchmark']['total']) ." (".grading_the_result($data['benchmark']['total'])['rating'].")".''; $result .= ''; echo $result; From dd53776ba3c6d8b155e58b41654078bee0cd00e3 Mon Sep 17 00:00:00 2001 From: AmiiirCom Date: Tue, 30 Jul 2024 03:48:47 +0330 Subject: [PATCH 2/2] Update benchmark.php --- benchmark.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark.php b/benchmark.php index af6ad09..d2552df 100644 --- a/benchmark.php +++ b/benchmark.php @@ -188,7 +188,7 @@ function grading_the_result($total){ $number = $matches[0]; - if ( $number <= 0.150 ){ + if ( $number > 0 and $number <= 0.150 ){ $grade = array( 'color' => '#5ec52b', 'rating' => 'Excellent'