diff options
author | Hilmar R <u02@u29lx193> | 2021-02-28 21:06:16 +0100 |
---|---|---|
committer | Hilmar R <u02@u29lx193> | 2021-03-01 18:48:11 +0100 |
commit | c26dede97f626b52b7bf8962ed55d1dbda86abe8 (patch) | |
tree | 3c8c9bc97aa09f7ce9afe9bf467cf87bbf2c7d0b /vendor/brick/math/random-tests.php | |
parent | ea3390d626f85b7293a750958bfd1b5460958365 (diff) | |
download | volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.gz volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.tar.bz2 volse-hubzilla-c26dede97f626b52b7bf8962ed55d1dbda86abe8.zip |
get dev
Diffstat (limited to 'vendor/brick/math/random-tests.php')
-rw-r--r-- | vendor/brick/math/random-tests.php | 26 |
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; } } |