aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/brick/math/random-tests.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-02-15 18:27:20 +0000
committerMario <mario@mariovavti.com>2021-02-15 18:27:20 +0000
commit18c8f1b903e90ca3632520b90d21ec3770bf6e0b (patch)
tree542ce373170e5693d32516aa11d7569ed312ad03 /vendor/brick/math/random-tests.php
parent4171a0136ad4f14bdd5d7621b4c7decd3e942c8c (diff)
downloadvolse-hubzilla-18c8f1b903e90ca3632520b90d21ec3770bf6e0b.tar.gz
volse-hubzilla-18c8f1b903e90ca3632520b90d21ec3770bf6e0b.tar.bz2
volse-hubzilla-18c8f1b903e90ca3632520b90d21ec3770bf6e0b.zip
composer update brick/math
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;
}
}