mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 09:30:55 +00:00
dict.c benchmark: take optional count argument.
This commit is contained in:
parent
91a59e03a8
commit
1074f73629
14
src/dict.c
14
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user