Files
natsnet/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/JetStreamBenchmarks.Impltests.cs

29 lines
743 B
C#

using System.Diagnostics;
using Shouldly;
using ZB.MOM.NatsNet.Server;
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
public sealed class JetStreamBenchmarks
{
[Fact]
public void BenchmarkJetStreamMetaSnapshot()
{
var started = Stopwatch.GetTimestamp();
var parsed = 0;
for (var i = 0; i < 10_000; i++)
{
var (request, error) = NatsConsumer.NextReqFromMsg("{\"batch\":1}"u8);
error.ShouldBeNull();
request.ShouldNotBeNull();
if (request!.Batch == 1)
parsed++;
}
parsed.ShouldBe(10_000);
var elapsed = Stopwatch.GetElapsedTime(started);
elapsed.ShouldBeLessThan(TimeSpan.FromSeconds(5));
}
}