MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / stressGetKeys

Function stressGetKeys

utils/hashtable/rehashing.c:72–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72void stressGetKeys(dict *d, int times, int *perfect_run, int *approx_run) {
73 int j;
74
75 dictEntry **des = zmalloc(sizeof(dictEntry*)*dictSize(d), MALLOC_SHARED);
76 for (j = 0; j < times; j++) {
77 int requested = rand() % (dictSize(d)+1);
78 int returned = dictGetSomeKeys(d, des, requested);
79 int dup = 0;
80
81 qsort(des,returned,sizeof(dictEntry*),sortPointers);
82 if (returned > 1) {
83 int i;
84 for (i = 0; i < returned-1; i++) {
85 if (des[i] == des[i+1]) dup++;
86 }
87 }
88
89 if (requested == returned && dup == 0) {
90 (*perfect_run)++;
91 } else {
92 (*approx_run)++;
93 printf("Requested, returned, duplicated: %d %d %d\n",
94 requested, returned, dup);
95 }
96 }
97 zfree(des);
98}
99
100#define MAX1 120
101#define MAX2 1000

Callers 1

mainFunction · 0.85

Calls 3

zmallocFunction · 0.85
dictGetSomeKeysFunction · 0.85
zfreeFunction · 0.85

Tested by

no test coverage detected