summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-09-07 10:44:19 +0200
committerantirez <antirez@gmail.com>2016-09-07 10:44:29 +0200
commit1074f73629daab5937218ebac264704385fca8a3 (patch)
tree06a5b91aaa2eb24c7bc381c8ee387fe64e054a89
parent91a59e03a8be94cc8176637ccee4b0c92e6d5f58 (diff)
downloadredis-1074f73629daab5937218ebac264704385fca8a3.tar.gz
dict.c benchmark: take optional count argument.
-rw-r--r--src/dict.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/dict.c b/src/dict.c
index 39432956b..cbd47527f 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -1123,19 +1123,27 @@ dictType BenchmarkDictType = {
NULL
};
-int main(void) {
+/* dict-benchmark [count] */
+int main(int argc, char **argv) {
long j;
long hits = 0, misses = 0;
long long start, elapsed;
dict *dict = dictCreate(&BenchmarkDictType,NULL);
+ long count = 0;
+
+ if (argc == 2) {
+ count = strtol(argv[1],NULL,10);
+ } else {
+ count = 5000000;
+ }
start = timeInMilliseconds();
- for (j = 0; j < 5000000; j++) {
+ for (j = 0; j < count; j++) {
int retval = dictAdd(dict,sdsfromlonglong(j),(void*)j);
assert(retval == DICT_OK);
}
elapsed = timeInMilliseconds()-start;
printf("Inserting 5M items: %lld ms\n", elapsed);
- assert(dictSize(dict) == 5000000);
+ assert((long)dictSize(dict) == count);
}
#endif