aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick/math/random-tests.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/brick/math/random-tests.php')
-rw-r--r--vendor/brick/math/random-tests.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/vendor/brick/math/random-tests.php b/vendor/brick/math/random-tests.php
index c59529f6f..d9053fc11 100644
--- a/vendor/brick/math/random-tests.php
+++ b/vendor/brick/math/random-tests.php
@@ -64,7 +64,7 @@ use Brick\Math\Internal\Calculator;
* @param string $a The left operand.
* @param string $b The right operand.
*/
- function runTests(string $a, string $b) : void
+ private function runTests(string $a, string $b) : void
{
$this->test("$a + $b", function(Calculator $c) use($a, $b) {
return $c->add($a, $b);
@@ -123,8 +123,11 @@ use Brick\Math\Internal\Calculator;
*/
private function test(string $test, Closure $callback) : void
{
- static $counter = 0;
- static $lastOutputTime = null;
+ static $testCounter = 0;
+ static $lastOutputTime = 0.0;
+ static $currentSecond = 0;
+ static $currentSecondTestCounter = 0;
+ static $testsPerSecond = 0;
$gmpResult = $callback($this->gmp);
$bcmathResult = $callback($this->bcmath);
@@ -138,13 +141,20 @@ use Brick\Math\Internal\Calculator;
self::failure('GMP', 'Native', $test);
}
- $counter++;
+ $testCounter++;
+ $currentSecondTestCounter++;
+
$time = microtime(true);
+ $second = (int) $time;
- if ($lastOutputTime === null) {
- $lastOutputTime = $time;
- } elseif ($time - $lastOutputTime >= 0.1) {
- echo "\r", number_format($counter);
+ if ($second !== $currentSecond) {
+ $currentSecond = $second;
+ $testsPerSecond = $currentSecondTestCounter;
+ $currentSecondTestCounter = 0;
+ }
+
+ if ($time - $lastOutputTime >= 0.1) {
+ echo "\r", number_format($testCounter), ' (', number_format($testsPerSecond) . ' / s)';
$lastOutputTime = $time;
}
}