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

Feature request: Report 1/2 memory #8

Open
hopeseekr opened this issue Oct 6, 2015 · 5 comments
Open

Feature request: Report 1/2 memory #8

hopeseekr opened this issue Oct 6, 2015 · 5 comments

Comments

@hopeseekr
Copy link

Please have PHPUnit report half the amount of actual memory used in the CI environment ;-)

@hugues-m
Copy link
Owner

hugues-m commented Oct 7, 2015

Any idea how to spoof memory_get_peak_usage() ? ^^

@radekk
Copy link

radekk commented Oct 7, 2015

You could use runkit extension. Remember to set appropriate flag (internal_override) inside php configuration file i.e. /etc/php/5.5/conf.d/ext-runkit.ini:

[runkit]
extension="/usr/local/opt/php55-runkit/runkit.so"
runkit.internal_override = On

Result:

php > var_dump(memory_get_peak_usage());
int(236288)
php > runkit_function_copy('memory_get_peak_usage', 'memory_get_peak_usage_old');
php > runkit_function_redefine('memory_get_peak_usage', '', 'return (memory_get_peak_usage_old() / 2);');
php > var_dump(memory_get_peak_usage());
int(122432)

Ref:

@evillemez
Copy link

+1 my job depends on this

@hugues-m
Copy link
Owner

hugues-m commented Oct 8, 2015

The moment you install the runkit extension you loose the battle !
It would be easy to even rewrite PhpUnit methods to display unicorns instead of test results.
But I don't see any dev in his right mind installing this php extension, and I think part of the fun of this component is its ease of installation and usage ^^

@hopeseekr
Copy link
Author

We will not say how I know this, but you can manipulate the literal text of PHPUnit using ob_get_clean() and judicious use of preg_replace() followed with an echo. Try doing this in your endTestSuite() of the listener.

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

No branches or pull requests

4 participants