Commit f2e7109e authored by Marc Gravell's avatar Marc Gravell

investigate #898

parent 2b789576
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" /> <PackageReference Include="BenchmarkDotNet" Version="0.11.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
using System; using System;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Attributes;
...@@ -22,8 +23,9 @@ internal class CustomConfig : ManualConfig ...@@ -22,8 +23,9 @@ internal class CustomConfig : ManualConfig
public CustomConfig() public CustomConfig()
{ {
Job Get(Job j) => j Job Get(Job j) => j
.With(new GcMode { Force = true }); .With(new GcMode { Force = true })
//.With(InProcessToolchain.Instance); .With(InProcessToolchain.Instance)
;
Add(new MemoryDiagnoser()); Add(new MemoryDiagnoser());
Add(StatisticColumn.OperationsPerSecond); Add(StatisticColumn.OperationsPerSecond);
...@@ -157,4 +159,70 @@ public async Task<int> ExecuteGeoRadiusAsync() ...@@ -157,4 +159,70 @@ public async Task<int> ExecuteGeoRadiusAsync()
return total; 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 @@ ...@@ -17,7 +17,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.10.14" /> <PackageReference Include="BenchmarkDotNet" Version="0.11.0" />
</ItemGroup> </ItemGroup>
<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