Codeception / Codeception/Codeception
[Feature] Show peak memory usage for each executed test
- Dominant language
- PHP
- Stars
- 4.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes, when you have many tests for an application, it can be difficult to know when where a component or parts of the system has a memory leak or just consumes a lot of memory. To make it a bit easier to identify such situations, it would be really nice if the default console output could include peak memory usage, per test.
## Possible Solution
Ideally, this feature should be added when running PHP `v8.2` and upwards, such that [`memory_get_peak_usage()`](https://www.php.net/manual/en/function.memory-get-peak-usage.php) and [`memory_reset_peak_usage`](https://www.php.net/manual/en/function.memory-reset-peak-usage.php).
Thus far, I think that it can be implemented as part of the `\Codeception\Subscriber\Console::writelnFinishedTest()` method, just after the execution time is shown.
However, I'm not that familiar with Codeception's internals... Maybe `\Codeception\Test\Test` and `\Codeception\Event\TestEvent` should be updated to support a memory used value? In any case, this would be a small and yet very useful feature.
## References
* [How to get and reset peak memory usage](https://php.watch/versions/8.2/memory_reset_peak_usage)
Contributor guide
Assessment
This issue has not been assessed yet.