From b4f85484eac7d469ec332045b7a28b0639ab468b Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Thu, 31 Mar 2011 12:41:46 +0200 Subject: Add pipelined throughput tests --- test.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/test.c b/test.c index e9173a0..3b58cbc 100644 --- a/test.c +++ b/test.c @@ -354,7 +354,7 @@ static void test_throughput(void) { t2 = usec(); for (i = 0; i < 1000; i++) freeReplyObject(replies[i]); free(replies); - printf("\t(1000x PING: %.2fs)\n", (t2-t1)/1000000.0); + printf("\t(1000x PING: %.3fs)\n", (t2-t1)/1000000.0); replies = malloc(sizeof(redisReply*)*1000); t1 = usec(); @@ -366,7 +366,34 @@ static void test_throughput(void) { t2 = usec(); for (i = 0; i < 1000; i++) freeReplyObject(replies[i]); free(replies); - printf("\t(1000x LRANGE with 500 elements: %.2fs)\n", (t2-t1)/1000000.0); + printf("\t(1000x LRANGE with 500 elements: %.3fs)\n", (t2-t1)/1000000.0); + + replies = malloc(sizeof(redisReply*)*10000); + for (i = 0; i < 10000; i++) + redisAppendCommand(c,"PING"); + t1 = usec(); + for (i = 0; i < 10000; i++) { + assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK); + assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_STATUS); + } + t2 = usec(); + for (i = 0; i < 10000; i++) freeReplyObject(replies[i]); + free(replies); + printf("\t(10000x PING (pipelined): %.3fs)\n", (t2-t1)/1000000.0); + + replies = malloc(sizeof(redisReply*)*10000); + for (i = 0; i < 10000; i++) + redisAppendCommand(c,"LRANGE mylist 0 499"); + t1 = usec(); + for (i = 0; i < 10000; i++) { + assert(redisGetReply(c, (void*)&replies[i]) == REDIS_OK); + assert(replies[i] != NULL && replies[i]->type == REDIS_REPLY_ARRAY); + assert(replies[i] != NULL && replies[i]->elements == 500); + } + t2 = usec(); + for (i = 0; i < 10000; i++) freeReplyObject(replies[i]); + free(replies); + printf("\t(10000x LRANGE with 500 elements: %.3fs)\n", (t2-t1)/1000000.0); } static void cleanup(void) { -- cgit v1.2.3