mirror of https://github.com/Squidex/squidex.git
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.
52 lines
1.5 KiB
52 lines
1.5 KiB
// ==========================================================================
|
|
// AppendToEventStoreWithManyWriters.cs
|
|
// Squidex Headless CMS
|
|
// ==========================================================================
|
|
// Copyright (c) Squidex Group
|
|
// All rights reserved.
|
|
// ==========================================================================
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using Benchmarks.Utils;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Squidex.Infrastructure.EventSourcing;
|
|
|
|
namespace Benchmarks.Tests
|
|
{
|
|
public sealed class AppendToEventStoreWithManyWriters : 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 = 200;
|
|
const long numStreams = 100;
|
|
|
|
Parallel.For(0, numStreams, streamId =>
|
|
{
|
|
var streamName = streamId.ToString();
|
|
|
|
for (var commitId = 0; commitId < numCommits; commitId++)
|
|
{
|
|
eventStore.AppendEventsAsync(Guid.NewGuid(), streamName, new[] { Helper.CreateEventData() }).Wait();
|
|
}
|
|
});
|
|
|
|
return numCommits * numStreams;
|
|
}
|
|
|
|
public override void RunCleanup()
|
|
{
|
|
services.Cleanup();
|
|
}
|
|
}
|
|
}
|
|
|