]> git.saurik.com Git - redis.git/commitdiff
benchmarking with different number of LRANGE elements. Ability to change the glue...
authorantirez <antirez@gmail.com>
Wed, 18 Nov 2009 18:41:25 +0000 (19:41 +0100)
committerantirez <antirez@gmail.com>
Wed, 18 Nov 2009 18:41:25 +0000 (19:41 +0100)
benchmark.c
redis.c

index bf8e2834d9422224f578b231f4f6fa42b40883b5..a933eba9c48ca4c2ccb0628548944d40f01d6b74 100644 (file)
@@ -574,6 +574,24 @@ int main(int argc, char **argv) {
         aeMain(config.el);
         endBenchmark("LRANGE (first 300 elements)");
 
         aeMain(config.el);
         endBenchmark("LRANGE (first 300 elements)");
 
+        prepareForBenchmark();
+        c = createClient();
+        if (!c) exit(1);
+        c->obuf = sdscat(c->obuf,"LRANGE mylist 0 449\r\n");
+        prepareClientForReply(c,REPLY_MBULK);
+        createMissingClients(c);
+        aeMain(config.el);
+        endBenchmark("LRANGE (first 450 elements)");
+
+        prepareForBenchmark();
+        c = createClient();
+        if (!c) exit(1);
+        c->obuf = sdscat(c->obuf,"LRANGE mylist 0 599\r\n");
+        prepareClientForReply(c,REPLY_MBULK);
+        createMissingClients(c);
+        aeMain(config.el);
+        endBenchmark("LRANGE (first 600 elements)");
+
         printf("\n");
     } while(config.loop);
 
         printf("\n");
     } while(config.loop);
 
diff --git a/redis.c b/redis.c
index 35843845cd1c6b03c29b019d7496d9fcfdb6ea4b..52143e56735e271dd0a909239530a2192ea3284f 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -1349,6 +1349,7 @@ static void freeClient(redisClient *c) {
     zfree(c);
 }
 
     zfree(c);
 }
 
+#define GLUEREPLY_UP_TO (1024)
 static void glueReplyBuffersIfNeeded(redisClient *c) {
     int totlen = 0;
     listNode *ln;
 static void glueReplyBuffersIfNeeded(redisClient *c) {
     int totlen = 0;
     listNode *ln;
@@ -1360,10 +1361,10 @@ static void glueReplyBuffersIfNeeded(redisClient *c) {
         totlen += sdslen(o->ptr);
         /* This optimization makes more sense if we don't have to copy
          * too much data */
         totlen += sdslen(o->ptr);
         /* This optimization makes more sense if we don't have to copy
          * too much data */
-        if (totlen > 1024) return;
+        if (totlen > GLUEREPLY_UP_TO) return;
     }
     if (totlen > 0) {
     }
     if (totlen > 0) {
-        char buf[1024];
+        char buf[GLUEREPLY_UP_TO];
         int copylen = 0;
 
         listRewind(c->reply);
         int copylen = 0;
 
         listRewind(c->reply);