summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-09-07 15:27:25 +0200
committerantirez <antirez@gmail.com>2016-09-07 15:28:40 +0200
commit0d179d17ba8a93d0a74ea8ecbbe383cc884fcb85 (patch)
treea7a6733beaca7f842230cd5d68710fe88baff55e
parentbd6c4cade6d2d3c19309cf8251656a0336d6bd7f (diff)
downloadredis-0d179d17ba8a93d0a74ea8ecbbe383cc884fcb85.tar.gz
dict.c benchmark minor improvements.
-rw-r--r--src/dict.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/dict.c b/src/dict.c
index b15ae4876..e37b659e6 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -1157,12 +1157,30 @@ int main(int argc, char **argv) {
start_benchmark();
for (j = 0; j < count; j++) {
+ sds key = sdsfromlonglong(j);
+ dictEntry *de = dictFind(dict,key);
+ assert(de != NULL);
+ sdsfree(key);
+ }
+ end_benchmark("Linear access of existing elements");
+
+ start_benchmark();
+ for (j = 0; j < count; j++) {
+ sds key = sdsfromlonglong(j);
+ dictEntry *de = dictFind(dict,key);
+ assert(de != NULL);
+ sdsfree(key);
+ }
+ end_benchmark("Linear access of existing elements (2nd round)");
+
+ start_benchmark();
+ for (j = 0; j < count; j++) {
sds key = sdsfromlonglong(rand() % count);
dictEntry *de = dictFind(dict,key);
assert(de != NULL);
sdsfree(key);
}
- end_benchmark("Accessing existing");
+ end_benchmark("Random access of existing elements");
start_benchmark();
for (j = 0; j < count; j++) {