diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 03c6ac453..842b019f1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -68,7 +68,7 @@ jobs: - name: "phpbench diff" id: bench - run: 'vendor/bin/phpbench run tests/Benchmark --progress=none --report=diff --ref=base --assert="mode(variant.time.avg) <= mode(baseline.time.avg) +/- 5%" --assert="mode(variant.mem.peak) <= mode(baseline.mem.peak) +/- 5%" > bench.txt' + run: 'vendor/bin/phpbench run tests/Benchmark --progress=none --report=diff --ref=base > bench.txt' - name: "Get Bench Result" if: ${{ success() || (failure() && steps.bench.conclusion == 'failure') }} diff --git a/baseline.xml b/baseline.xml index 8ccb58382..f3b3ae266 100644 --- a/baseline.xml +++ b/baseline.xml @@ -133,15 +133,17 @@ </file> <file src="tests/Benchmark/PersonalDataBench.php"> <MissingConstructor> - <code><![CDATA[$id]]></code> + <code><![CDATA[$multipleEventsId]]></code> <code><![CDATA[$repository]]></code> + <code><![CDATA[$singleEventId]]></code> <code><![CDATA[$store]]></code> </MissingConstructor> </file> <file src="tests/Benchmark/SimpleSetupBench.php"> <MissingConstructor> - <code><![CDATA[$id]]></code> + <code><![CDATA[$multipleEventsId]]></code> <code><![CDATA[$repository]]></code> + <code><![CDATA[$singleEventId]]></code> <code><![CDATA[$store]]></code> </MissingConstructor> </file> diff --git a/tests/Benchmark/PersonalDataBench.php b/tests/Benchmark/PersonalDataBench.php index 7cd530e78..f20eb17ac 100644 --- a/tests/Benchmark/PersonalDataBench.php +++ b/tests/Benchmark/PersonalDataBench.php @@ -27,7 +27,8 @@ final class PersonalDataBench private Store $store; private Repository $repository; - private AggregateRootId $id; + private AggregateRootId $singleEventId; + private AggregateRootId $multipleEventsId; public function setUp(): void { @@ -65,9 +66,12 @@ public function setUp(): void $schemaDirector->create(); - $this->id = ProfileId::v7(); + $this->singleEventId = ProfileId::v7(); + $profile = Profile::create($this->singleEventId, 'Peter'); + $this->repository->save($profile); - $profile = Profile::create($this->id, 'Peter', 'info@patchlevel.de'); + $this->multipleEventsId = ProfileId::v7(); + $profile = Profile::create($this->multipleEventsId, 'Peter', 'info@patchlevel.de'); for ($i = 0; $i < 10_000; $i++) { $profile->changeEmail('info@patchlevel.de'); @@ -76,10 +80,16 @@ public function setUp(): void $this->repository->save($profile); } + #[Bench\Revs(10)] + public function benchLoad1Event(): void + { + $this->repository->load($this->singleEventId); + } + #[Bench\Revs(10)] public function benchLoad10000Events(): void { - $this->repository->load($this->id); + $this->repository->load($this->multipleEventsId); } #[Bench\Revs(10)] diff --git a/tests/Benchmark/SimpleSetupBench.php b/tests/Benchmark/SimpleSetupBench.php index 7a98b46b2..8f63d0916 100644 --- a/tests/Benchmark/SimpleSetupBench.php +++ b/tests/Benchmark/SimpleSetupBench.php @@ -22,7 +22,8 @@ final class SimpleSetupBench private Store $store; private Repository $repository; - private AggregateRootId $id; + private AggregateRootId $singleEventId; + private AggregateRootId $multipleEventsId; public function setUp(): void { @@ -42,9 +43,12 @@ public function setUp(): void $schemaDirector->create(); - $this->id = ProfileId::v7(); + $this->singleEventId = ProfileId::v7(); + $profile = Profile::create($this->singleEventId, 'Peter'); + $this->repository->save($profile); - $profile = Profile::create($this->id, 'Peter'); + $this->multipleEventsId = ProfileId::v7(); + $profile = Profile::create($this->multipleEventsId, 'Peter'); for ($i = 0; $i < 10_000; $i++) { $profile->changeName('Peter'); @@ -53,10 +57,16 @@ public function setUp(): void $this->repository->save($profile); } + #[Bench\Revs(10)] + public function benchLoad1Event(): void + { + $this->repository->load($this->singleEventId); + } + #[Bench\Revs(10)] public function benchLoad10000Events(): void { - $this->repository->load($this->id); + $this->repository->load($this->multipleEventsId); } #[Bench\Revs(10)]