Commit f4f93131 authored by antirez's avatar antirez
Browse files

redis-benchmark: replace snprintf()+memcpy with faster code.

This change was profiler-driven, but the actual effect is hard to
measure in real-world redis benchmark runs.
parent 702f3afe
...@@ -151,13 +151,18 @@ static void resetClient(client c) { ...@@ -151,13 +151,18 @@ static void resetClient(client c) {
} }
static void randomizeClientKey(client c) { static void randomizeClientKey(client c) {
char buf[32]; size_t i;
size_t i, r;
for (i = 0; i < c->randlen; i++) { for (i = 0; i < c->randlen; i++) {
r = random() % config.randomkeys_keyspacelen; char *p = c->randptr[i]+11;
snprintf(buf,sizeof(buf),"%012zu",r); size_t r = random() % config.randomkeys_keyspacelen;
memcpy(c->randptr[i],buf,12); size_t j;
for (j = 0; j < 12; j++) {
*p = '0'+r%10;
r/=10;
p--;
}
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment