Skip to content

Commit

Permalink
improve setup for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed May 3, 2022
1 parent c497d30 commit 3d1499c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
11 changes: 4 additions & 7 deletions baseline.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.22.0@fc2c6ab4d5fa5d644d8617089f012f3bb84b8703">
<file src="src/Serializer/Hydrator/MetadataAggregateRootHydrator.php">
<InaccessibleProperty occurrences="1">
<code>$aggregateRoot-&gt;playhead</code>
</InaccessibleProperty>
</file>
<file src="src/Store/MultiTableStore.php">
<UnnecessaryVarAnnotation occurrences="1">
<code>array{id: string, aggregate_id: string, playhead: string, event: string, payload: string, recorded_on: string}|null</code>
</UnnecessaryVarAnnotation>
</file>
<file src="tests/Benchmark/LoadEventsBench.php">
<MissingConstructor occurrences="2">
<MissingConstructor occurrences="3">
<code>$bus</code>
<code>$repository</code>
<code>$store</code>
</MissingConstructor>
</file>
<file src="tests/Benchmark/LoadEventsWithSnapshotsBench.php">
<MissingConstructor occurrences="3">
<MissingConstructor occurrences="4">
<code>$bus</code>
<code>$repository</code>
<code>$snapshotStore</code>
<code>$store</code>
</MissingConstructor>
Expand Down
10 changes: 5 additions & 5 deletions tests/Benchmark/LoadEventsBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Patchlevel\EventSourcing\EventBus\EventBus;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AttributeAggregateRootRegistryFactory;
use Patchlevel\EventSourcing\Repository\DefaultRepository;
use Patchlevel\EventSourcing\Repository\Repository;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaManager;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
use Patchlevel\EventSourcing\Store\SingleTableStore;
Expand All @@ -28,6 +29,7 @@ final class LoadEventsBench

private Store $store;
private EventBus $bus;
private Repository $repository;

public function setUp(): void
{
Expand All @@ -49,7 +51,7 @@ public function setUp(): void
'eventstore'
);

$repository = new DefaultRepository($this->store, $this->bus, Profile::class);
$this->repository = new DefaultRepository($this->store, $this->bus, Profile::class);

// create tables
(new DoctrineSchemaManager())->create($this->store);
Expand All @@ -60,15 +62,13 @@ public function setUp(): void
$profile->changeName('Peter');
}

$repository->save($profile);
$this->repository->save($profile);
}

#[Bench\Revs(10)]
#[Bench\Iterations(2)]
public function benchLoadEvents(): void
{
$repository = new DefaultRepository($this->store, $this->bus, Profile::class);

$repository->load('1');
$this->repository->load('1');
}
}
10 changes: 5 additions & 5 deletions tests/Benchmark/LoadEventsWithSnapshotsBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Patchlevel\EventSourcing\EventBus\EventBus;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AttributeAggregateRootRegistryFactory;
use Patchlevel\EventSourcing\Repository\DefaultRepository;
use Patchlevel\EventSourcing\Repository\Repository;
use Patchlevel\EventSourcing\Schema\DoctrineSchemaManager;
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
use Patchlevel\EventSourcing\Snapshot\Adapter\InMemorySnapshotAdapter;
Expand All @@ -32,6 +33,7 @@ final class LoadEventsWithSnapshotsBench
private Store $store;
private EventBus $bus;
private SnapshotStore $snapshotStore;
private Repository $repository;

public function setUp(): void
{
Expand All @@ -55,7 +57,7 @@ public function setUp(): void

$this->snapshotStore = new DefaultSnapshotStore(['default' => new InMemorySnapshotAdapter()]);

$repository = new DefaultRepository($this->store, $this->bus, Profile::class, $this->snapshotStore);
$this->repository = new DefaultRepository($this->store, $this->bus, Profile::class, $this->snapshotStore);

// create tables
(new DoctrineSchemaManager())->create($this->store);
Expand All @@ -66,16 +68,14 @@ public function setUp(): void
$profile->changeName('Peter');
}

$repository->save($profile);
$this->repository->save($profile);
$this->snapshotStore->save($profile);
}

#[Bench\Revs(10)]
#[Bench\Iterations(2)]
public function benchLoadEvents(): void
{
$repository = new DefaultRepository($this->store, $this->bus, Profile::class, $this->snapshotStore);

$repository->load('1');
$this->repository->load('1');
}
}

0 comments on commit 3d1499c

Please sign in to comment.