Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
1.5 KiB

// ==========================================================================
// AppendToEventStore.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using Benchmarks.Utils;
using Microsoft.Extensions.DependencyInjection;
using Squidex.Infrastructure.EventSourcing;
namespace Benchmarks.Tests
{
public sealed class AppendToEventStore : Benchmark
{
private IServiceProvider services;
private IEventStore eventStore;
public override void RunInitialize()
{
services = Services.Create();
eventStore = services.GetRequiredService<IEventStore>();
}
public override long Run()
{
const long numCommits = 100;
const long numStreams = 20;
for (var streamId = 0; streamId < numStreams; streamId++)
{
var eventOffset = -1;
var streamName = streamId.ToString();
for (var commitId = 0; commitId < numCommits; commitId++)
{
eventStore.AppendEventsAsync(Guid.NewGuid(), streamName, eventOffset, new[] { Helper.CreateEventData() }).Wait();
eventOffset++;
}
}
return numCommits * numStreams;
}
public override void RunCleanup()
{
services.Cleanup();
}
}
}