示例#1
0
        private void Run()
        {
            RSLClient rslClient = new RSLClient(serviceIdentity, "KV", ps.Verbose);

            Thread.Sleep(3000);

            Random rng = new Random();

            for (int requestNum = 1; true; ++requestNum)
            {
                KVRequest request      = GetRandomRequest(rng, ps);
                byte[]    requestBytes = request.Encode();
                var       startTime    = HiResTimer.Ticks;
                byte[]    replyBytes   = rslClient.SubmitRequest(requestBytes, ps.Verbose);
                var       endTime      = HiResTimer.Ticks;
                KVReply   reply        = KVReply.Decode(replyBytes, 0);

                if (ps.PrintRequestsAndReplies)
                {
                    Console.WriteLine("Received reply of type {0}", reply.ReplyType);
                    if (reply is KVGetFoundReply gfr)
                    {
                        Console.WriteLine("Value obtained for get was {0}", gfr.Val);
                    }
                }
                Console.WriteLine("#req {0} {1} {2}",
                                  id,
                                  requestNum,
                                  HiResTimer.TicksToMilliseconds(endTime - startTime));
            }
        }
示例#2
0
        private void Run()
        {
            RSLClient rslClient = new RSLClient(serviceIdentity, "Counter", ps.Verbose);

            Thread.Sleep(3000);

            for (int requestNum = 1; true; ++requestNum)
            {
                var    request      = new IncrementRequest();
                byte[] requestBytes = request.Encode();
                var    startTime    = HiResTimer.Ticks;
                byte[] replyBytes   = rslClient.SubmitRequest(requestBytes, ps.Verbose);
                var    endTime      = HiResTimer.Ticks;
                var    reply        = IncrementReply.Decode(replyBytes);
                if (ps.PrintReplies)
                {
                    Console.WriteLine("Received increment reply with counter {0}", reply.counterValue);
                }
                Console.WriteLine("#req {0} {1} {2}",
                                  id,
                                  requestNum,
                                  HiResTimer.TicksToMilliseconds(endTime - startTime));
            }
        }