Exemplo n.º 1
0
        public static void Run(object obj)
        {
            Tuple <int, int> tuple = (Tuple <int, int>)obj;
            int          partition = tuple.Item1, clientIndex = tuple.Item2;
            IRedisClient redisClient = clients[clientIndex];

            // PinThreadOnCores(clientIndex);

            // debug
            Console.WriteLine("{0}:{1}", redisClient.Host, redisClient.Port);

            SLIM.Wait();
            long beginTicks = DateTime.Now.Ticks;

            for (int i = 0; i < BATCHES; i++)
            {
                using (IRedisPipeline pipe = redisClient.CreatePipeline())
                {
                    string hashId = StaticRandom.RandIdentity().ToString();
                    byte[] key    = BitConverter.GetBytes(StaticRandom.RandIdentity());
                    for (int j = 0; j < 100; j++)
                    {
                        pipe.QueueCommand(r => ((RedisNativeClient)r).HGet(hashId, key));
                    }
                    pipe.Flush();
                }
            }
            long endTicks = DateTime.Now.Ticks;

            int throughput = (int)(BATCHES * 100 * 1.0 / ((endTicks - beginTicks) * 1.0 / 10000000));
            // Console.WriteLine("Single Thread Throughput: {0}", throughput);
        }