// Console.WriteLine("* redis lregion[50-60]"); ConsoleWait.Start(); result = OnTest(Config.RedisClient, LRegionHandler1TO2); ConsoleWait.End(); Console.WriteLine(result); Console.WriteLine("* ssdb lregion[50-60]"); ConsoleWait.Start(); result = OnTest(Config.SSDBClient, LRegionHandler1TO2); ConsoleWait.End(); Console.WriteLine(result); Console.WriteLine("* -----------------------------------------------"); // Console.WriteLine("* redis lregion[100-110]"); ConsoleWait.Start(); result = OnTest(Config.RedisClient, LRegionHandler1TO2); ConsoleWait.End(); Console.WriteLine(result); Console.WriteLine("* ssdb lregion[100-110]"); ConsoleWait.Start(); result = OnTest(Config.SSDBClient, LRegionHandler1TO2); ConsoleWait.End(); Console.WriteLine(result); Console.WriteLine("* -----------------------------------------------"); // Console.WriteLine("* redis hget"); ConsoleWait.Start(); result = OnTest(Config.RedisClient, HGetHandler); ConsoleWait.End(); Console.WriteLine(result); Console.WriteLine("* ssdb hget"); ConsoleWait.Start(); result = OnTest(Config.SSDBClient, HGetHandler); ConsoleWait.End(); Console.WriteLine(result); Console.WriteLine("* -----------------------------------------------"); } private void HGetHandler(RedisClient e) { while (mRuning) { long index = System.Threading.Interlocked.Increment(ref mIndex); ProtobufKey key = "user_" + Data.Import.Users[(int)(index % Data.Import.Users.Count)].Name; key.Get<Model.Order, Model.Employee, Model.Customer>(e); System.Threading.Interlocked.Increment(ref mCount); } } private void LRegionHandler1TO2(RedisClient e) { while (mRuning) { ProtobufList<Model.Order> list = "Orders"; list.Range(1, 2, e); System.Threading.Interlocked.Increment(ref mCount); } } private void LRegionHandler50TO60(RedisClient e) { while (mRuning) { ProtobufList<Model.Order> list = "Orders"; list.Range(50, 60, e); System.Threading.Interlocked.Increment(ref mCount); } } private void LRegionHandler100TO110(RedisClient e) { while (mRuning) { ProtobufList<Model.Order> list = "Orders"; list.Range(100, 110, e); System.Threading.Interlocked.Increment(ref mCount); } } private void GetHandler(RedisClient e) { while (mRuning) { long index = System.Threading.Interlocked.Increment(ref mIndex); ProtobufKey key = "user_" + Data.Import.Users[(int)(index % Data.Import.Users.Count)].Name; key.Get<Model.User>(e); System.Threading.Interlocked.Increment(ref mCount); } } private string OnTest(RedisClient client,Action<RedisClient> handler) { mCount = 0; mRuning = true; for (int i = 0; i < 20; i++) { System.Threading.ThreadPool.QueueUserWorkItem((o) => { GetHandler((RedisClient)o); }, client); } int s = 20; while (s > 0) { System.Threading.Thread.Sleep(1000); s--; } mRuning = false; System.Threading.Thread.Sleep(1000); return string.Format("* [seconds:{1}/total:{0}]", mCount, mCount / 20); } } |