Commit 0ad5c405 authored by Marc Gravell's avatar Marc Gravell

use the perf test added recently; rev lib

parent 9a213f91
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="1.0.20" /> <PackageReference Include="Pipelines.Sockets.Unofficial" Version="1.0.26" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.5.0" /> <PackageReference Include="System.Diagnostics.PerformanceCounter" Version="4.5.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.5.1" /> <PackageReference Include="System.IO.Pipelines" Version="4.5.1" />
<PackageReference Include="System.Threading.Channels" Version="4.5.0" /> <PackageReference Include="System.Threading.Channels" Version="4.5.0" />
......
using System; using System;
using System.Linq;
using System.Threading.Tasks;
using StackExchange.Redis; using StackExchange.Redis;
namespace TestConsole namespace TestConsole
{ {
internal static class Program internal static class Program
{ {
public static void Main() public static async Task Main()
{ {
var client = ConnectionMultiplexer.Connect("localhost");
client.GetDatabase().Ping();
var db = client.GetDatabase(0);
var start = DateTime.Now;
Show(client.GetCounters());
var tasks = Enumerable.Range(0, 1000).Select(async i =>
{
for (int t = 0; t < 1000; t++)
{
await db.StringIncrementAsync(i.ToString(), 1);
// db.StringIncrement(i.ToString(), 1);
}
await Task.Yield();
});
await Task.WhenAll(tasks);
Show(client.GetCounters());
var duration = DateTime.Now.Subtract(start).TotalMilliseconds;
Console.WriteLine($"{duration}ms");
}
private static void Show(ServerCounters counters)
{
Console.WriteLine("CA: " + counters.Interactive.CompletedAsynchronously);
Console.WriteLine("FA: " + counters.Interactive.FailedAsynchronously);
Console.WriteLine("CS: " + counters.Interactive.CompletedSynchronously);
Console.WriteLine();
} }
} }
} }
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