Created
June 28, 2012 11:26
-
-
Save seiji/3010771 to your computer and use it in GitHub Desktop.
redis-benchmark-sortedset.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git src/redis-benchmark.c src/redis-benchmark.c | |
| index 19eb491..34ee0d3 100644 | |
| --- src/redis-benchmark.c | |
| +++ src/redis-benchmark.c | |
| @@ -73,6 +73,10 @@ static struct config { | |
| int loop; | |
| int idlemode; | |
| char *tests; | |
| + | |
| + /* add zincr */ | |
| + int member_init; | |
| + int member_progress; | |
| } config; | |
| typedef struct _client { | |
| @@ -127,6 +131,7 @@ static void freeClient(client c) { | |
| static void freeAllClients(void) { | |
| listNode *ln = config.clients->head, *next; | |
| + config.member_progress = config.member_init; | |
| while(ln) { | |
| next = ln->next; | |
| freeClient(ln->value); | |
| @@ -153,6 +158,15 @@ static void randomizeClientKey(client c) { | |
| } | |
| } | |
| +static void randomizeClientMember(client c) { /* for sortedset */ | |
| + char *p = c->obuf; | |
| + while ((p = strstr(p,":member:")) != NULL) { | |
| + char str[9]; | |
| + sprintf(str, "%08d", config.member_progress++); | |
| + memcpy(p, str, 8); | |
| + } | |
| +} | |
| + | |
| static void clientDone(client c) { | |
| if (config.requests_finished == config.requests) { | |
| freeClient(c); | |
| @@ -223,6 +237,7 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) { | |
| return; | |
| } | |
| + if (config.member_init) randomizeClientMember(c); | |
| /* Really initialize: randomize keys and set start time. */ | |
| if (config.randomkeys) randomizeClientKey(c); | |
| c->start = ustime(); | |
| @@ -529,6 +544,8 @@ int main(int argc, const char **argv) { | |
| config.hostsocket = NULL; | |
| config.tests = NULL; | |
| + config.member_init = 10000000; | |
| + config.member_progress = 10000000; | |
| i = parseOptions(argc,argv); | |
| argc -= i; | |
| argv += i; | |
| @@ -657,6 +674,37 @@ int main(int argc, const char **argv) { | |
| free(cmd); | |
| } | |
| + if (test_is_selected("zincrby") || | |
| + test_is_selected("zcount") || | |
| + test_is_selected("zrevrange") || | |
| + test_is_selected("zrevrank") || | |
| + test_is_selected("zscore")) | |
| + { | |
| + len = redisFormatCommand(&cmd,"ZINCRBY mySortedSet %d %s",100000, ":member:"); | |
| + benchmark("ZINCRBY ",cmd,len); | |
| + free(cmd); | |
| + } | |
| + if (test_is_selected("zcount")) { | |
| + len = redisFormatCommand(&cmd,"ZCOUNT mySortedSet 0 +inf"); | |
| + benchmark("ZCOUNT ",cmd,len); | |
| + free(cmd); | |
| + } | |
| + if (test_is_selected("zrevrange")) { | |
| + len = redisFormatCommand(&cmd,"ZREVRANGE mySortedSet 0 20"); | |
| + benchmark("ZREVRANGE ",cmd,len); | |
| + free(cmd); | |
| + } | |
| + if (test_is_selected("zrevrank")) { | |
| + len = redisFormatCommand(&cmd,"ZREVRANK mySortedSet %s", ":member:"); | |
| + benchmark("ZREVRANK ",cmd,len); | |
| + free(cmd); | |
| + } | |
| + if (test_is_selected("zscore")) { | |
| + len = redisFormatCommand(&cmd,"ZSCORE mySortedSet %s", ":member:"); | |
| + benchmark("ZSCORE ",cmd,len); | |
| + free(cmd); | |
| + } | |
| + | |
| if (test_is_selected("mset")) { | |
| const char *argv[21]; | |
| argv[0] = "MSET"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment