MCPcopy Create free account
hub / github.com/F-Stack/f-stack / dictTest

Function dictTest

app/redis-6.2.6/src/dict.c:1229–1314  ·  view source on GitHub ↗

./redis-server test dict [ | --accurate] */

Source from the content-addressed store, hash-verified

1227
1228/* ./redis-server test dict [<count> | --accurate] */
1229int dictTest(int argc, char **argv, int accurate) {
1230 long j;
1231 long long start, elapsed;
1232 dict *dict = dictCreate(&BenchmarkDictType,NULL);
1233 long count = 0;
1234
1235 if (argc == 4) {
1236 if (accurate) {
1237 count = 5000000;
1238 } else {
1239 count = strtol(argv[3],NULL,10);
1240 }
1241 } else {
1242 count = 5000;
1243 }
1244
1245 start_benchmark();
1246 for (j = 0; j < count; j++) {
1247 int retval = dictAdd(dict,stringFromLongLong(j),(void*)j);
1248 assert(retval == DICT_OK);
1249 }
1250 end_benchmark("Inserting");
1251 assert((long)dictSize(dict) == count);
1252
1253 /* Wait for rehashing. */
1254 while (dictIsRehashing(dict)) {
1255 dictRehashMilliseconds(dict,100);
1256 }
1257
1258 start_benchmark();
1259 for (j = 0; j < count; j++) {
1260 char *key = stringFromLongLong(j);
1261 dictEntry *de = dictFind(dict,key);
1262 assert(de != NULL);
1263 zfree(key);
1264 }
1265 end_benchmark("Linear access of existing elements");
1266
1267 start_benchmark();
1268 for (j = 0; j < count; j++) {
1269 char *key = stringFromLongLong(j);
1270 dictEntry *de = dictFind(dict,key);
1271 assert(de != NULL);
1272 zfree(key);
1273 }
1274 end_benchmark("Linear access of existing elements (2nd round)");
1275
1276 start_benchmark();
1277 for (j = 0; j < count; j++) {
1278 char *key = stringFromLongLong(rand() % count);
1279 dictEntry *de = dictFind(dict,key);
1280 assert(de != NULL);
1281 zfree(key);
1282 }
1283 end_benchmark("Random access of existing elements");
1284
1285 start_benchmark();
1286 for (j = 0; j < count; j++) {

Callers

nothing calls this directly

Calls 10

strtolFunction · 0.85
stringFromLongLongFunction · 0.85
dictRehashMillisecondsFunction · 0.85
dictGetRandomKeyFunction · 0.85
dictCreateFunction · 0.70
dictAddFunction · 0.70
dictFindFunction · 0.70
zfreeFunction · 0.70
dictDeleteFunction · 0.70
dictReleaseFunction · 0.70

Tested by

no test coverage detected