Codeception / Codeception/Codeception

[Feature] Show peak memory usage for each executed test

Open
#6,628 4 comments 2 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.