MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / test_stress

Function test_stress

3rd/mimalloc-2.0.9/test/test-stress.c:182–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180static void run_os_threads(size_t nthreads, void (*entry)(intptr_t tid));
181
182static void test_stress(void) {
183 uintptr_t r = rand();
184 for (int n = 0; n < ITER; n++) {
185 run_os_threads(THREADS, &stress);
186 for (int i = 0; i < TRANSFERS; i++) {
187 if (chance(50, &r) || n + 1 == ITER) { // free all on last run, otherwise free half of the transfers
188 void* p = atomic_exchange_ptr(&transfer[i], NULL);
189 free_items(p);
190 }
191 }
192 #ifndef NDEBUG
193 //mi_collect(false);
194 //mi_debug_show_arenas();
195 #endif
196 #if !defined(NDEBUG) || defined(MI_TSAN)
197 if ((n + 1) % 10 == 0) { printf("- iterations left: %3d\n", ITER - (n + 1)); }
198 #endif
199 }
200}
201
202#ifndef STRESS
203static void leak(intptr_t tid) {

Callers 1

mainFunction · 0.85

Calls 4

run_os_threadsFunction · 0.85
chanceFunction · 0.85
atomic_exchange_ptrFunction · 0.85
free_itemsFunction · 0.85

Tested by

no test coverage detected