private static void MultigetSpeedTest() { //Enyim.Caching.LogManager.AssignFactory(new ConsoleLogFactory()); var tmc = new MemcachedClientConfiguration(); tmc.AddServer("172.16.203.2:11211"); tmc.AddServer("172.16.203.2:11212"); //tmc.AddServer("172.16.203.2:11213"); //tmc.AddServer("172.16.203.2:11214"); tmc.Protocol = MemcachedProtocol.Binary; //tmc.SocketPool.MinPoolSize = 1; //tmc.SocketPool.MaxPoolSize = 1; tmc.SocketPool.ReceiveTimeout = new TimeSpan(0, 0, 4); tmc.SocketPool.ConnectionTimeout = new TimeSpan(0, 0, 4); tmc.KeyTransformer = new DefaultKeyTransformer(); var tc = new MemcachedClient(tmc); const string KeyPrefix = "asdfghjkl"; var val = new byte[10 * 1024]; val[val.Length - 1] = 1; for (var i = 0; i < 100; i++) if (!tc.Store(StoreMode.Set, KeyPrefix + i, val)) Console.WriteLine("Fail " + KeyPrefix + i); var keys = Enumerable.Range(0, 500).Select(k => KeyPrefix + k).ToArray(); Console.WriteLine("+"); var sw = Stopwatch.StartNew(); //tc.Get(KeyPrefix + "4"); //sw.Stop(); //Console.WriteLine(sw.ElapsedMilliseconds); //sw = Stopwatch.StartNew(); //var p = tc.Get2(keys); //sw.Stop(); //Console.WriteLine(sw.ElapsedMilliseconds); //sw = Stopwatch.StartNew(); //var t = tc.Get(keys); //Console.WriteLine(" --" + t.Count); //sw.Stop(); //Console.WriteLine(sw.ElapsedMilliseconds); //Console.WriteLine("Waiting"); //Console.ReadLine(); //return; for (var i = 0; i < 100; i++) { const int MAX = 300; sw = Stopwatch.StartNew(); for (var j = 0; j < MAX; j++) tc.Get(keys); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); sw = Stopwatch.StartNew(); for (var j = 0; j < MAX; j++) tc.GetOld(keys); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); //sw = Stopwatch.StartNew(); //for (var j = 0; j < MAX; j++) // foreach (var k in keys) tc.Get(k); //sw.Stop(); //Console.WriteLine(sw.ElapsedMilliseconds); Console.WriteLine("----"); } Console.ReadLine(); return; }