StackExchange.Redis 根据发布线程对命令进行分组
示例
ConnectionMultiplexer conn = /* initialization */;
var profiler = new ToyProfiler();conn.RegisterProfiler(profiler);
var threads = new List<Thread>();
var perThreadTimings = new ConcurrentDictionary<Thread, List<IProfiledCommand>>();
for (var i = 0; i < 16; i++)
{
var db = conn.GetDatabase(i);
var thread =
new Thread(
delegate()
{
var threadTasks = new List<Task>();
conn.BeginProfiling(Thread.CurrentThread);
for (var j = 0; j < 1000; j++)
{
var task = db.StringSetAsync("" + j, "" + j);
threadTasks.Add(task);
}
Task.WaitAll(threadTasks.ToArray());
perThreadTimings[Thread.CurrentThread] = conn.FinishProfiling(Thread.CurrentThread).ToList();
}
);
profiler.Contexts[thread] = thread;
threads.Add(thread);
}
threads.ForEach(thread => thread.Start());
threads.ForEach(thread => thread.Join());perThreadTimings最终以1,000个IProfilingCommands的16个条目结束,由发出它们的线程键入。
热门推荐
10 学生祝福语简短古诗大全
11 祝福语签名简短大全女生
12 爱情寄语简短祝福语大全
13 回复同事新年祝福语简短
14 煽情的生日祝福语简短
15 新进单位敬酒祝福语简短
16 周末祝福语简短老师的话
17 分公司祝福语简短独特
18 喜事作文结尾祝福语简短