Commit 4a8da46d authored by Marc Gravell's avatar Marc Gravell

tweaks

parent 16363206
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using StackExchange.Redis; using StackExchange.Redis;
...@@ -11,15 +12,21 @@ internal static class Program ...@@ -11,15 +12,21 @@ internal static class Program
{ {
private static void Main() private static void Main()
{ {
Console.WriteLine($"{Environment.OSVersion} / {Environment.Version} / {(Environment.Is64BitProcess ? "64" : "32")}");
Console.WriteLine(RuntimeInformation.FrameworkDescription);
for (int i = 0; i < 500; i++)
{
Console.WriteLine(i);
RunCompetingBatchesOnSameMuxer(); RunCompetingBatchesOnSameMuxer();
} }
}
static ConnectionMultiplexer Create() static ConnectionMultiplexer Create()
{ {
var muxer = ConnectionMultiplexer.Connect("localhost:6379"); var muxer = ConnectionMultiplexer.Connect("localhost:6379");
muxer.GetDatabase().Ping(); muxer.GetDatabase().Ping();
return muxer; return muxer;
} }
private const int IterationCount = 5000, InnerCount = 20; private const int IterationCount = 500, InnerCount = 20;
public static void RunCompetingBatchesOnSameMuxer() public static void RunCompetingBatchesOnSameMuxer()
{ {
using (var muxer = Create()) using (var muxer = Create())
...@@ -60,6 +67,7 @@ private static void BatchRunIntegers(IDatabase db) ...@@ -60,6 +67,7 @@ private static void BatchRunIntegers(IDatabase db)
} }
batch.Execute(); batch.Execute();
db.Multiplexer.WaitAll(tasks); db.Multiplexer.WaitAll(tasks);
if (i % 1000 == 0) Console.WriteLine(i);
} }
var count = (long)db.StringGet(key); var count = (long)db.StringGet(key);
...@@ -78,6 +86,7 @@ private static void BatchRunPings(IDatabase db) ...@@ -78,6 +86,7 @@ private static void BatchRunPings(IDatabase db)
} }
batch.Execute(); batch.Execute();
db.Multiplexer.WaitAll(tasks); db.Multiplexer.WaitAll(tasks);
if (i % 1000 == 0) Console.WriteLine(i);
} }
} }
} }
......
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