Open hopeseekr opened 9 years ago
Any idea how to spoof memory_get_peak_usage() ? ^^
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:
+1 my job depends on this
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 ^^
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.
Please have PHPUnit report half the amount of actual memory used in the CI environment ;-)