public void SetsPerSecondWith50ThreadsPipelined() { System.Diagnostics.Stopwatch sw = new Stopwatch(); long counter = 0; bool run = true; var evt = new ManualResetEvent(false); using (var pool = new PipelinedCommandFactoryPool(_host, 6379)) { var ts = new ThreadStart(() => { var f = pool.Get(); evt.WaitOne(); while (run) { f.Set("bar", "baz").Exec(); Interlocked.Increment(ref counter); } }); var workers = new System.Collections.Generic.List <Thread>(); for (int i = 0; i < 50; i++) { var t = new Thread(ts); t.Start(); workers.Add(t); } sw.Start(); evt.Set(); Thread.Sleep(30000); run = false; sw.Stop(); foreach (var t in workers) { t.Join(); } } Assert.Pass(String.Format("{0} Sets/Sec", counter * 1000.0 / sw.ElapsedMilliseconds)); }
public void SetsPerSecondWith50ThreadsPipelined() { System.Diagnostics.Stopwatch sw = new Stopwatch(); long counter = 0; bool run = true; var evt = new ManualResetEvent(false); using (var pool = new PipelinedCommandFactoryPool(_host, 6379)) { var ts = new ThreadStart(() => { var f = pool.Get(); evt.WaitOne(); while (run) { f.Set("bar", "baz").Exec(); Interlocked.Increment(ref counter); } }); var workers = new System.Collections.Generic.List<Thread>(); for (int i = 0; i < 50; i++) { var t = new Thread(ts); t.Start(); workers.Add(t); } sw.Start(); evt.Set(); Thread.Sleep(30000); run = false; sw.Stop(); foreach (var t in workers) { t.Join(); } } Assert.Pass(String.Format("{0} Sets/Sec", counter * 1000.0 / sw.ElapsedMilliseconds)); }