Skip to content

Commit

Permalink
Fix Single stream benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
sandrokeil committed Jul 15, 2020
1 parent 7825504 commit 259cf3f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/StreamCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,24 @@ public function run()

$start = \microtime(true);

$streamName = new StreamName($this->category . '-' . $this->id);

for ($i = 0; $i < $this->executions; $i++) {
$count += $this->numberOfEvents;
$streamName = $this->category . '-' . Uuid::uuid4()->toString();
$events = createTestEvents(testPayload(), $this->numberOfEvents);

if ($eventStore instanceof TransactionalEventStore) {
$eventStore->beginTransaction();
}

$eventStore->create(new Stream(new StreamName($streamName), \SplFixedArray::fromArray($events)));
if (getenv('STREAM_STRATEGY') === 'Aggregate') {
$streamName = $this->category . '-' . Uuid::uuid4()->toString();
$eventStore->create(new Stream(new StreamName($streamName), \SplFixedArray::fromArray($events)));
} elseif ($i === 0 && $eventStore->hasStream($streamName) === false) {
$eventStore->create(new Stream($streamName, \SplFixedArray::fromArray($events)));
} else {
$eventStore->appendTo($streamName, \SplFixedArray::fromArray($events));
}

if ($eventStore instanceof TransactionalEventStore) {
$eventStore->commit();
Expand Down

0 comments on commit 259cf3f

Please sign in to comment.