Skip to content

Commit 73600c5

Browse files
Merge branch '11.5' into 12.1
2 parents 5b2ace8 + 1bb53c6 commit 73600c5

File tree

5 files changed

+12
-42
lines changed

5 files changed

+12
-42
lines changed

ChangeLog-12.1.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes of the PHPUnit 12.1 release series are documented in this fi
44

55
## [12.1.3] - 2025-MM-DD
66

7+
### Changed
8+
9+
* When gathering the telemetry information that each event has, the real size of memory allocated from the operating system is no longer used as this is grown by PHP's memory manager in chunks that are so large that small(er) increases in peak memory usage cannot be seen
10+
* The peak memory usage returned by `memory_get_peak_usage()` is now reset immediately before the `Test\Prepared` event is emitted using `memory_reset_peak_usage()` so that (memory usage at `Test\Finished` - memory usage at `Test\Prepared`) is a better approximation of the the memory usage of the test
11+
* The string representation of `Telemetry\Info` now uses peak memory usage instead of memory usage (this affects `--log-events-verbose-text`)
12+
713
### Fixed
814

915
* [#6173](https://github.com/sebastianbergmann/phpunit/issues/6173): Output from `error_log()` is not displayed when test fails

src/Event/Emitter/DispatchingEmitter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace PHPUnit\Event;
1111

1212
use function assert;
13+
use function memory_reset_peak_usage;
1314
use PHPUnit\Event\Code\ClassMethod;
1415
use PHPUnit\Event\Code\ComparisonFailure;
1516
use PHPUnit\Event\Code\IssueTrigger\IssueTrigger;
@@ -492,6 +493,8 @@ public function preConditionFinished(TestMethod $test, ClassMethod ...$calledMet
492493
*/
493494
public function testPrepared(Code\Test $test): void
494495
{
496+
memory_reset_peak_usage();
497+
495498
$this->dispatcher->dispatch(
496499
new Test\Prepared(
497500
$this->telemetryInfo(),

src/Event/Value/Telemetry/Info.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function asString(): string
7979
'[%s / %s] [%d bytes]',
8080
$this->durationSinceStart()->asString(),
8181
$this->durationSincePrevious()->asString(),
82-
$this->memoryUsage()->bytes(),
82+
$this->peakMemoryUsage()->bytes(),
8383
);
8484
}
8585
}

src/Event/Value/Telemetry/SystemMemoryMeter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
{
2222
public function memoryUsage(): MemoryUsage
2323
{
24-
return MemoryUsage::fromBytes(memory_get_usage(true));
24+
return MemoryUsage::fromBytes(memory_get_usage());
2525
}
2626

2727
public function peakMemoryUsage(): MemoryUsage
2828
{
29-
return MemoryUsage::fromBytes(memory_get_peak_usage(true));
29+
return MemoryUsage::fromBytes(memory_get_peak_usage());
3030
}
3131
}

tests/unit/Event/Value/Telemetry/SystemMemoryMeterTest.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)