Codeception: Codeception with codecoverage painfully slow

I hope to get some help here, because I’ve asked the same question on stackoverflow and got no feedback.

I am using codeception (with codecoverage) to check the code coverage of an application I have written using the Yii2 framework. Because the standard php installation on my mac has xcode not enabled, I activated it adding a zend_module line to my php.ini. Code coverage seems to work now but is painfully slow. Yes I know that the activated xdebug and coverage generation takes some time, but I think this is not normal: Even a simple unit test which checks only the initialization of an object takes up to 15 minutes.

I don’t think that it is a cpu or ram problem rather than a configuration problem.

I start code coverage with:

codeception run unit --coverage-html

Things I detected: The first test runs always fast regardless how big it is. The second test is much slower (regardless what test it is) and the third is more slowly. How can I track this down? I want to detect the problem.

Again: I know that codecoverage slows down tests, but 15 minutes for a simple test is not normal. The test that runs approx. 15 minutes, takes 1 second without code-coverage enabled.

I am using the latest codeception version running on a macbook air.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

I did tracked the slow code coverage down. In my case it was the coverage blacklist that was causing the slow down (and even ‘Maximum execution time’ exceptions). It has probably to do with the performance of arrays in php. The class Codeception\Coverage\Filter spend more than 80% of the time in the function ‘blackList’ timing out at line 109 or 110:

foreach ($finder as $file) {
    $filter->addFileToBlacklist($file);
}

Workaround: when possible don’t use coverage->blacklist and/or coverage->whitelist->exclude in your codeception.yml (so basically only use coverage->whitelist->include)

Still actual… Running API tests under Docker is painfully slow, consumes a lot of CPU and each test can consume up to several seconds!

I don’t know what is behind this, but this should be optimised as it brings a lot of pain and hurts CI pipeline where all these tests should run as fast as possible, not consuming too much resources…