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

Function main

app/redis-6.2.6/utils/hashtable/rehashing.c:102–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100#define MAX1 120
101#define MAX2 1000
102int main(void) {
103 dict *d = dictCreate(&dictTypeTest,NULL);
104 unsigned long i;
105 srand(time(NULL));
106
107 for (i = 0; i < MAX1; i++) {
108 dictAdd(d,(void*)i,NULL);
109 show(d);
110 }
111 printf("Size: %d\n", (int)dictSize(d));
112
113 for (i = 0; i < MAX1; i++) {
114 dictDelete(d,(void*)i);
115 dictResize(d);
116 show(d);
117 }
118 dictRelease(d);
119
120 d = dictCreate(&dictTypeTest,NULL);
121
122 printf("Stress testing dictGetSomeKeys\n");
123 int perfect_run = 0, approx_run = 0;
124
125 for (i = 0; i < MAX2; i++) {
126 dictAdd(d,(void*)i,NULL);
127 stressGetKeys(d,100,&perfect_run,&approx_run);
128 }
129
130 for (i = 0; i < MAX2; i++) {
131 dictDelete(d,(void*)i);
132 dictResize(d);
133 stressGetKeys(d,100,&perfect_run,&approx_run);
134 }
135
136 printf("dictGetSomeKey, %d perfect runs, %d approximated runs\n",
137 perfect_run, approx_run);
138
139 dictRelease(d);
140
141 printf("TEST PASSED!\n");
142 return 0;
143}

Callers

nothing calls this directly

Calls 8

showFunction · 0.85
dictResizeFunction · 0.85
stressGetKeysFunction · 0.85
dictCreateFunction · 0.50
dictAddFunction · 0.50
printfFunction · 0.50
dictDeleteFunction · 0.50
dictReleaseFunction · 0.50

Tested by

no test coverage detected