From 0d179d17ba8a93d0a74ea8ecbbe383cc884fcb85 Mon Sep 17 00:00:00 2001 From: antirez <antirez@gmail.com> Date: Wed, 7 Sep 2016 15:27:25 +0200 Subject: [PATCH] dict.c benchmark minor improvements. --- src/dict.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/dict.c b/src/dict.c index b15ae487..e37b659e 100644 --- a/src/dict.c +++ b/src/dict.c @@ -1155,6 +1155,24 @@ int main(int argc, char **argv) { dictRehashMilliseconds(dict,100); } + 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); @@ -1162,7 +1180,7 @@ int main(int argc, char **argv) { assert(de != NULL); sdsfree(key); } - end_benchmark("Accessing existing"); + end_benchmark("Random access of existing elements"); start_benchmark(); for (j = 0; j < count; j++) {