Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Benchmark] Add loading only 1 event #567

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
6 changes: 4 additions & 2 deletions baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
18 changes: 14 additions & 4 deletions tests/Benchmark/PersonalDataBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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');
Expand All @@ -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)]
Expand Down
18 changes: 14 additions & 4 deletions tests/Benchmark/SimpleSetupBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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');
Expand All @@ -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)]
Expand Down
Loading