Skip to content

Conversation

@derickr
Copy link
Contributor

@derickr derickr commented Jul 26, 2020

With this change, both PHP Code Coverage's and PHPUnit's test suite still passes.
It makes the PHPUnit test suite run in approximately ⅔rds of the time, with no differences in output:

output-diff

PHPUnit's test suite ($ php -dxdebug.mode=coverage,profile -dxdebug.start_with_request=yes -dhtml_errors=0 -dmemory_limit=2G ./phpunit --testsuite=unit --coverage-html=/tmp/cov-after.html):

  • Before: Time: 00:52.085, Memory: 82.00 MB
  • After: Time: 00:33.547, Memory: 82.00 MB, a reduction of 36%.

The valgrind/cachegrind profile shows it is using only 27% of its previous instructions.

/tmp/callgrind.phpunit-coverage.2020-07-25-02-profile-refs.before-pr.out: totals: 178 198 995 103
/tmp/callgrind.phpunit-coverage.2020-07-25-02-profile-refs.out:totals:             48 225 236 059

@codecov
Copy link

codecov bot commented Jul 26, 2020

Codecov Report

Merging #783 into master will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #783      +/-   ##
============================================
- Coverage     84.29%   84.28%   -0.01%     
+ Complexity     1074     1072       -2     
============================================
  Files            56       56              
  Lines          3234     3233       -1     
============================================
- Hits           2726     2725       -1     
  Misses          508      508              
Impacted Files Coverage Δ Complexity Δ
src/ProcessedCodeCoverageData.php 100.00% <100.00%> (ø) 53.00 <0.00> (-2.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e584265...944419f. Read the comment docs.

if (empty($this->lineCoverage[$file][$k]) || !in_array($testCaseId, $this->lineCoverage[$file][$k], true)) {
$this->lineCoverage[$file][$k][] = $testCaseId;
}
$this->lineCoverage[$file][$k][] = $testCaseId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is safe, then the checks on 83/91 (pre-patch) 81/89 (post-patch) I think should be safe to remove as well, the principle behind adding those was cargo-culting over from this one

Copy link

@exussum12 exussum12 Jul 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what happens in this case but it's possible for the same test to be added to this array twice now.

If the array was keyed by the test id, you could set the key to be the id and the value to be true ? Then use array_keys before processing.

Not checked if adding the same test matters though

@sebastianbergmann sebastianbergmann merged commit 505bcb4 into sebastianbergmann:master Jul 27, 2020
sebastianbergmann added a commit that referenced this pull request Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants