-
-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New event appending performance harness
- Loading branch information
1 parent
9863907
commit b81646e
Showing
16 changed files
with
78,330 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/EventAppenderPerfTester/EventAppenderPerfTester.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DaemonTests\DaemonTests.csproj" /> | ||
<ProjectReference Include="..\Marten.CommandLine\Marten.CommandLine.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Runtime.CompilerServices; | ||
using DaemonTests.TestingSupport; | ||
using Oakton; | ||
using Xunit.Abstractions; | ||
|
||
namespace EventAppenderPerfTester; | ||
|
||
public class ExportCommand : OaktonAsyncCommand<NetCoreInput> | ||
{ | ||
public override async Task<bool> Execute(NetCoreInput input) | ||
{ | ||
using var host = input.BuildHost(); | ||
var trips = new List<TripStream>(); | ||
for (int i = 0; i < 100; i++) | ||
{ | ||
trips.Add(new TripStream()); | ||
} | ||
|
||
await TripStreamReaderWriter.Write(trips.ToArray()); | ||
|
||
Console.WriteLine("Wrote 100 trip streams to " + TripStreamReaderWriter.Path); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Marten; | ||
|
||
namespace EventAppenderPerfTester; | ||
|
||
public interface ITestPlan | ||
{ | ||
Task Execute(IDocumentSession session); | ||
void FetchData(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using DaemonTests.TestingSupport; | ||
using Marten; | ||
|
||
namespace EventAppenderPerfTester; | ||
|
||
public class MultiplesTestPlan: ITestPlan | ||
{ | ||
private List<TripStream[]> _data; | ||
|
||
public async Task Execute(IDocumentSession session) | ||
{ | ||
foreach (var trips in _data) | ||
{ | ||
await TripStream.PublishMultiplesSimple(session, trips); | ||
} | ||
} | ||
|
||
public void FetchData() | ||
{ | ||
_data = TripStreamReaderWriter.ReadPages(100, 10); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Marten; | ||
using Marten.Events; | ||
using Marten.Events.Projections; | ||
using Marten.Testing.Harness; | ||
using Microsoft.Extensions.Hosting; | ||
using Oakton; | ||
|
||
var builder = Host.CreateDefaultBuilder(); | ||
builder.ConfigureServices(services => | ||
{ | ||
services.AddMarten(opts => | ||
{ | ||
opts.Connection(ConnectionSource.ConnectionString); | ||
|
||
opts.DisableNpgsqlLogging = true; | ||
|
||
opts.Events.AppendMode = EventAppendMode.Quick; | ||
opts.Events.UseIdentityMapForInlineAggregates = true; | ||
|
||
opts.Projections.Add<DaemonTests.TestingSupport.TripProjection>(ProjectionLifecycle.Inline); | ||
}); | ||
}); | ||
|
||
return await builder.RunOaktonCommands(args); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using Oakton; | ||
|
||
namespace EventAppenderPerfTester; | ||
|
||
public class ReadCommand : OaktonAsyncCommand<NetCoreInput> | ||
{ | ||
public override async Task<bool> Execute(NetCoreInput input) | ||
{ | ||
using var host = input.BuildHost(); | ||
var trips = TripStreamReaderWriter.Read(); | ||
|
||
Console.WriteLine("Read trips"); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Testing Results | ||
|
||
Baseline: | ||
|
||
``` | ||
┌───────────────────────────┬──────────────────────────┐ | ||
│ Test Name │ Duration in milliseconds │ | ||
├───────────────────────────┼──────────────────────────┤ | ||
│ SingleFileSimple │ 5502 │ | ||
│ SingleFileFetchForWriting │ 5031 │ | ||
│ Multiples │ 27929 │ | ||
└───────────────────────────┴──────────────────────────┘ | ||
``` | ||
|
||
Adding Quick Append: | ||
|
||
``` | ||
┌───────────────────────────┬──────────────────────────┐ | ||
│ Test Name │ Duration in milliseconds │ | ||
├───────────────────────────┼──────────────────────────┤ | ||
│ SingleFileSimple │ 4517 │ | ||
│ SingleFileFetchForWriting │ 3338 │ | ||
│ Multiples │ 14722 │ | ||
└───────────────────────────┴──────────────────────────┘ | ||
``` | ||
|
||
Quick Append and the Inline + FetchForWriting thing: | ||
|
||
``` | ||
┌───────────────────────────┬──────────────────────────┐ | ||
│ Test Name │ Duration in milliseconds │ | ||
├───────────────────────────┼──────────────────────────┤ | ||
│ SingleFileSimple │ 4234 │ | ||
│ SingleFileFetchForWriting │ 3054 │ | ||
│ Multiples │ 15171 │ | ||
└───────────────────────────┴──────────────────────────┘ | ||
``` |
22 changes: 22 additions & 0 deletions
22
src/EventAppenderPerfTester/SingleFileFetchForWritingPlan.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using DaemonTests.TestingSupport; | ||
using Marten; | ||
|
||
namespace EventAppenderPerfTester; | ||
|
||
public class SingleFileFetchForWritingPlan: ITestPlan | ||
{ | ||
private List<TripStream> _data; | ||
|
||
public async Task Execute(IDocumentSession session) | ||
{ | ||
foreach (var tripStream in _data) | ||
{ | ||
await tripStream.PublishSingleFileWithFetchForWriting(session); | ||
} | ||
} | ||
|
||
public void FetchData() | ||
{ | ||
_data = TripStreamReaderWriter.ReadPages(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using DaemonTests.TestingSupport; | ||
using Marten; | ||
|
||
namespace EventAppenderPerfTester; | ||
|
||
public class SingleFileSimplePlan: ITestPlan | ||
{ | ||
private List<TripStream> _data; | ||
|
||
public async Task Execute(IDocumentSession session) | ||
{ | ||
foreach (var tripStream in _data) | ||
{ | ||
await tripStream.PublishSingleFileSimple(session); | ||
} | ||
} | ||
|
||
public void FetchData() | ||
{ | ||
_data = TripStreamReaderWriter.ReadPages(1); | ||
} | ||
} |
Oops, something went wrong.