//
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);
}
}
  从测试结果看来差距还是非常明显,并不象官网那样说得这么理想.虽然SSDB效率上不如REDIS,但其基于磁盘存储有着其大的优势,毕竟很多业务数据远超过服务器内存的容量.
  SSDB的测试结果不理想也许是硬件环境受限,如果有个SSD硬盘的测试环境估计也得到一个更好的结果,但在测试过程中发现一个问题是SSDB占用的CPU资源也是非常大的,在以上测试过程SSDB的并发效率比不上REDIS,同时CPU损耗上基本要比REDIS高出一倍的样子.
  以上测试结果紧紧是是一些情况下的性能测试对比,不能完全表述出两者在应用的差距的结果,如果需要用到这些产品的同学不防在实施前进行一些测试为实施选择提供一个更可靠的结果.