Commit f2e7109e authored by Marc Gravell's avatar Marc Gravell

investigate #898

parent 2b789576
......@@ -12,7 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" />
<PackageReference Include="BenchmarkDotNet" Version="0.11.0" />
</ItemGroup>
<ItemGroup>
......
using System;
using System.Diagnostics;
using System.Reflection;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
......@@ -22,8 +23,9 @@ internal class CustomConfig : ManualConfig
public CustomConfig()
{
Job Get(Job j) => j
.With(new GcMode { Force = true });
//.With(InProcessToolchain.Instance);
.With(new GcMode { Force = true })
.With(InProcessToolchain.Instance)
;
Add(new MemoryDiagnoser());
Add(StatisticColumn.OperationsPerSecond);
......@@ -157,4 +159,70 @@ public async Task<int> ExecuteGeoRadiusAsync()
return total;
}
}
#pragma warning disable CS1591
[Config(typeof(CustomConfig))]
public class Issue898 : IDisposable
{
private readonly ConnectionMultiplexer mux;
private readonly IDatabase db;
public void Dispose() => mux?.Dispose();
public Issue898()
{
mux = ConnectionMultiplexer.Connect("localhost:6379");
db = mux.GetDatabase();
}
const int max = 100000;
[Benchmark(OperationsPerInvoke = max)]
public void Load()
{
for (int i = 0; i < max; ++i)
{
db.StringSet(i.ToString(), i);
}
}
[Benchmark(OperationsPerInvoke = max)]
public async Task LoadAsync()
{
for (int i = 0; i < max; ++i)
{
await db.StringSetAsync(i.ToString(), i);
}
}
[Benchmark(OperationsPerInvoke = max)]
public void Sample()
{
var rnd = new Random();
for (int i = 0; i < max; ++i)
{
var r = rnd.Next(0, max - 1);
var rv = db.StringGet(r.ToString());
if (rv != r)
{
throw new Exception($"Unexpected {rv}, expected {r}");
}
}
}
[Benchmark(OperationsPerInvoke = max)]
public async Task SampleAsync()
{
var rnd = new Random();
for (int i = 0; i < max; ++i)
{
var r = rnd.Next(0, max - 1);
var rv = await db.StringGetAsync(r.ToString());
if (rv != r)
{
throw new Exception($"Unexpected {rv}, expected {r}");
}
}
}
}
}
......@@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" />
<PackageReference Include="BenchmarkDotNet" Version="0.11.0" />
</ItemGroup>
<ItemGroup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment