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.

Details

Related Gerrit Patches:

Event Timeline

Anomie created this task.Feb 1 2018, 9:25 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 1 2018, 9:25 PM

Change 407520 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/core@master] Benchmarker: Don't try to divide by zero

https://gerrit.wikimedia.org/r/407520

Krinkle closed this task as Resolved.Feb 2 2018, 2:25 AM
Krinkle assigned this task to Anomie.
Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Testing board.
Krinkle edited projects, added Performance-Team (Radar); removed Patch-For-Review.

Change 407520 merged by jenkins-bot:
[mediawiki/core@master] benchmarks: Fix divide by zero in Benchmarker

https://gerrit.wikimedia.org/r/407520