From ec6b51f70c70975cbd83856221d32f53eaa18dd0 Mon Sep 17 00:00:00 2001 From: Daniel Badura Date: Tue, 9 Apr 2024 12:43:46 +0200 Subject: [PATCH 1/4] Add loading only 1 event to the bench --- tests/Benchmark/PersonalDataBench.php | 19 +++++++++++++++---- tests/Benchmark/SimpleSetupBench.php | 18 ++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/tests/Benchmark/PersonalDataBench.php b/tests/Benchmark/PersonalDataBench.php index 7cd530e78..2f8b75650 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 { @@ -63,11 +64,15 @@ public function setUp(): void ]), ); + $schemaDirector->create(); $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 +81,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)] From 87877d0b94edebbfb7128c4aa688a2ac63bf4c2e Mon Sep 17 00:00:00 2001 From: Daniel Badura Date: Tue, 9 Apr 2024 12:44:01 +0200 Subject: [PATCH 2/4] Remove asserting in workflow. It is not reliable enough and the % diff in the new output should be sufficient --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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') }} From 1b8aa62d40fc43a92927bb6deec5a3fa99021d53 Mon Sep 17 00:00:00 2001 From: Daniel Badura Date: Tue, 9 Apr 2024 12:46:09 +0200 Subject: [PATCH 3/4] Dont create double --- tests/Benchmark/PersonalDataBench.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Benchmark/PersonalDataBench.php b/tests/Benchmark/PersonalDataBench.php index 2f8b75650..f20eb17ac 100644 --- a/tests/Benchmark/PersonalDataBench.php +++ b/tests/Benchmark/PersonalDataBench.php @@ -64,7 +64,6 @@ public function setUp(): void ]), ); - $schemaDirector->create(); $schemaDirector->create(); $this->singleEventId = ProfileId::v7(); From fb5817ff37c4b097f0599ab17868c2ab771f3a3e Mon Sep 17 00:00:00 2001 From: Daniel Badura Date: Tue, 9 Apr 2024 12:50:11 +0200 Subject: [PATCH 4/4] Update baseline --- baseline.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/baseline.xml b/baseline.xml index 8ccb58382..f3b3ae266 100644 --- a/baseline.xml +++ b/baseline.xml @@ -133,15 +133,17 @@ - + + - + +