Commit 7a2e6b56 authored by Marc Gravell's avatar Marc Gravell

merge

parent 1d8e9363
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Jobs; using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running; using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.InProcess;
using BenchmarkDotNet.Validators; using BenchmarkDotNet.Validators;
using StackExchange.Redis; using StackExchange.Redis;
...@@ -20,13 +21,14 @@ internal class CustomConfig : ManualConfig ...@@ -20,13 +21,14 @@ 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);
Add(new MemoryDiagnoser()); Add(new MemoryDiagnoser());
Add(StatisticColumn.OperationsPerSecond); Add(StatisticColumn.OperationsPerSecond);
Add(JitOptimizationsValidator.FailOnError); Add(JitOptimizationsValidator.FailOnError);
Add(Get(Job.Clr)); Add(Get(Job.Clr));
Add(Get(Job.Core)); //Add(Get(Job.Core));
} }
} }
/// <summary> /// <summary>
...@@ -35,19 +37,26 @@ public CustomConfig() ...@@ -35,19 +37,26 @@ public CustomConfig()
[Config(typeof(CustomConfig))] [Config(typeof(CustomConfig))]
public class RedisBenchmarks : IDisposable public class RedisBenchmarks : IDisposable
{ {
private ConnectionMultiplexer connection; SocketManager mgr;
private IDatabase db; ConnectionMultiplexer connection;
IDatabase db;
/// <summary> /// <summary>
/// Create /// Create
/// </summary> /// </summary>
public RedisBenchmarks() public RedisBenchmarks()
{ {
connection = ConnectionMultiplexer.Connect("127.0.0.1:6379,syncTimeout=200000"); mgr = new SocketManager(GetType().Name);
var options = ConfigurationOptions.Parse("127.0.0.1:6379,syncTimeout=1000");
options.SocketManager = mgr;
connection = ConnectionMultiplexer.Connect(options);
db = connection.GetDatabase(3); db = connection.GetDatabase(3);
} }
void IDisposable.Dispose() void IDisposable.Dispose()
{ {
mgr?.Dispose();
connection?.Dispose(); connection?.Dispose();
mgr = null;
db = null; db = null;
connection = null; connection = null;
} }
......
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq;
using StackExchange.Redis; using StackExchange.Redis;
namespace TestConsole namespace TestConsole
...@@ -24,11 +23,12 @@ private static int Main() ...@@ -24,11 +23,12 @@ private static int Main()
EndPoints = { "127.0.0.1:6381" }, EndPoints = { "127.0.0.1:6381" },
Password = "abc", Password = "abc",
}; };
using (var conn = ConnectionMultiplexer.Connect(config, log: s)) using (var conn = ConnectionMultiplexer.Connect(config, log: Console.Out))
{ {
Execute(conn); //Execute(conn);
} }
Console.WriteLine("Clean exit");
return 0; return 0;
} }
catch (Exception ex) catch (Exception ex)
...@@ -40,27 +40,20 @@ private static int Main() ...@@ -40,27 +40,20 @@ private static int Main()
{ {
watch.Stop(); watch.Stop();
Console.WriteLine(); Console.WriteLine();
Console.WriteLine($"{watch.ElapsedMilliseconds}ms"); Console.WriteLine($"{watch.ElapsedMilliseconds}ms (done)");
Console.WriteLine();
//Console.WriteLine(s);
Console.ReadKey();
} }
} }
private static void Execute(ConnectionMultiplexer conn) private static void Execute(ConnectionMultiplexer conn)
{ {
const int pageSize = 100; var key = "abc";
RedisKey key = nameof(Execute); Console.ReadKey();
var db = conn.GetDatabase(); var db = conn.GetDatabase(0);
db.KeyDelete(key); var t = db.CreateTransaction();
t.HashSetAsync(key, "foo", "bar");
for (int i = 0; i < 2000; i++) t.KeyExpireAsync(key, TimeSpan.FromSeconds(3600));
db.SetAdd(key, "s" + i, flags: CommandFlags.FireAndForget); t.Execute();
Console.ReadKey();
int count = db.SetScan(key, pageSize: pageSize).Count();
Console.WriteLine(count == 2000 ? "Pass" : "Fail");
} }
} }
} }
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