Skip to content

Commit 259cf3f

Browse files
committed
Fix Single stream benchmark
1 parent 7825504 commit 259cf3f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/StreamCreator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,24 @@ public function run()
4141

4242
$start = \microtime(true);
4343

44+
$streamName = new StreamName($this->category . '-' . $this->id);
45+
4446
for ($i = 0; $i < $this->executions; $i++) {
4547
$count += $this->numberOfEvents;
46-
$streamName = $this->category . '-' . Uuid::uuid4()->toString();
4748
$events = createTestEvents(testPayload(), $this->numberOfEvents);
4849

4950
if ($eventStore instanceof TransactionalEventStore) {
5051
$eventStore->beginTransaction();
5152
}
5253

53-
$eventStore->create(new Stream(new StreamName($streamName), \SplFixedArray::fromArray($events)));
54+
if (getenv('STREAM_STRATEGY') === 'Aggregate') {
55+
$streamName = $this->category . '-' . Uuid::uuid4()->toString();
56+
$eventStore->create(new Stream(new StreamName($streamName), \SplFixedArray::fromArray($events)));
57+
} elseif ($i === 0 && $eventStore->hasStream($streamName) === false) {
58+
$eventStore->create(new Stream($streamName, \SplFixedArray::fromArray($events)));
59+
} else {
60+
$eventStore->appendTo($streamName, \SplFixedArray::fromArray($events));
61+
}
5462

5563
if ($eventStore instanceof TransactionalEventStore) {
5664
$eventStore->commit();

0 commit comments

Comments
 (0)