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

merge

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