Page MenuHomePhabricator

BenchmarkerTest division by zero
Closed, ResolvedPublic

Description

Using PHP 7 to run tests, I find that occasionally a BenchmarkerTest fails with a "Division by 0" message. Usually just in just one test, but I've seen it happen in two as shown below.

Using PHP 7.0.27-1
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.

..E..E.

Time: 126 ms, Memory: 18.00MB

There were 2 errors:

1) MediaWiki\Tests\Maintenance\BenchmarkerTest::testBenchVerbose
Division by zero

/usr/local/src/MediaWiki/core/maintenance/benchmarks/Benchmarker.php:103
/usr/local/src/MediaWiki/core/tests/phpunit/maintenance/BenchmarkerTest.php:75
/usr/local/src/MediaWiki/core/maintenance/doMaintenance.php:94

2) MediaWiki\Tests\Maintenance\BenchmarkerTest::testVerboseRun
Division by zero

/usr/local/src/MediaWiki/core/maintenance/benchmarks/Benchmarker.php:103
/usr/local/src/MediaWiki/core/tests/phpunit/maintenance/BenchmarkerTest.php:140
/usr/local/src/MediaWiki/core/maintenance/doMaintenance.php:94

FAILURES!
Tests: 7, Assertions: 5, Errors: 2.

I wasn't able to get PHP5 or HHVM to do it in some quick attempts. Perhaps they're enough slower that they never wind up with a zero timing, or perhaps they have more accurate timers.