Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spread the word about fast code coverage via "pcov" extension #5531

Closed
splinter89 opened this issue May 31, 2019 · 9 comments
Closed

Spread the word about fast code coverage via "pcov" extension #5531

splinter89 opened this issue May 31, 2019 · 9 comments
Labels

Comments

@splinter89
Copy link
Contributor

What are you trying to achieve?

Let users know that Codeception 3 brings not only PHPUnit 8.x support, but also blazing-fast code coverage via krakjoe/pcov thanks to this bad boy sebastianbergmann/php-code-coverage#663

What do you get instead?

pcov is not mentioned anywhere 😞

Details

The setup is so simple, even your grandma can do it:

  • install pcov extension following these instructions
  • change defaults in your php.ini
    • disable xdebug by commenting out the line zend_extension=xdebug.so
    • enable pcov by adding extension=pcov.so and pcov.enabled = 1

Now, if you want code coverage, run vendor/bin/codecept --coverage-html
And if you need to debug some stuff, run php -d zend_extension=xdebug.so vendor/bin/codecept

This will help #1446, #4524, and also make lots of people really happy!

The running time of my tests with enabled code coverage went from 11 minutes down to 20 seconds.

@splinter89 splinter89 changed the title Spread the word about fast code coverage via pcov extension Spread the word about fast code coverage via "pcov" extension May 31, 2019
@Naktibalda Naktibalda added the Docs label Jun 2, 2019
@SamMousa
Copy link
Collaborator

SamMousa commented Jun 7, 2019

What are the advantages of pcov over phpdbg?

@splinter89
Copy link
Contributor Author

No overhead related to debugger functionality makes pcov faster than phpdbg.
It is also more precise because it properly handles implicit return statements (just like xdebug does, which is accurate but slow), see https://blog.krakjoe.ninja/2019/01/running-for-coverage.html

@Naktibalda
Copy link
Member

One small step which could be done is mentioning pcov in https://github.com/Codeception/Codeception/blob/3.0/docs/11-Codecoverage.md#remote-codecoverage
which currently says that To collect coverage information xdebug is required.

@alec-joy
Copy link

alec-joy commented Aug 1, 2019

What are the advantages of pcov over phpdbg?

Given how old this thread is you probably either already are using PCov or have decided not to use it, but the main advantage over PHPDbg in my experiences is not the speed (it is faster) but memory usage. PCov uses less memory than Xdebug or PHPDbg, the latter by a significant margin, and also happens to be faster than both (the former by a significant margin)

@mikehaertl
Copy link
Contributor

I've just tested this with the .phar based setup. It didn't work for me. I guess it's the included phpunit which is still version 6.5.14. So it either phpunit in the phar should be updated or it should be mentioned that pcov doesn't work with the phar setup.

@alec-joy
Copy link

alec-joy commented Sep 9, 2019

I've just tested this with the .phar based setup. It didn't work for me. I guess it's the included phpunit which is still version 6.5.14. So it either phpunit in the phar should be updated or it should be mentioned that pcov doesn't work with the phar setup.

I'm not familiar with the .phar install, do you mean the install for php 5.6 or the current .phar release for 7.x? I agree a note should/could be added able PCOV not working with PHP 5.6, it requires PHPUnit 8.0+ which doesn't support < 7.2.

@mikehaertl
Copy link
Contributor

I refer to the 7.x release (the one you get with wget https://codeception.com/codecept.phar or curl -LsS https://codeception.com/codecept.phar -o /usr/local/bin/codecept). I wonder why it doesn't include a newer version of phpunit and opened an issue for it here: #5676

On a sidenote: If you install with curl -LsS https://codeception.com/codecept.phar -o /usr/local/bin/codecept you will get version 3.0.3. If you then run codecept self-update, it will upgrade to 3.1.0 (which again includes an old version of phpunit). Made me wonder why it didn't download 3.1.0 directly.

@alec-joy
Copy link

alec-joy commented Sep 9, 2019

Huh, that's odd but understandable I suppose. The .phar install can't exactly upgrade it's dependencies so using the most compatible version of PHPUnit is probably the safe route.

@JorisVanEijden
Copy link

I'm currently using this dockerfile:

FROM codeception/codeception:3.1.0

RUN pecl install \
        pcov && \
    docker-php-ext-enable \
        pcov && \
    rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && \
    echo "pcov.directory = /project" >> /usr/local/etc/php/php.ini

This makes a big unit test suite running time go from 131 seconds to 13 seconds!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants