MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / main

Function main

test/pthread/test_large_pthread_allocation.c:32–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32int main() {
33 // This test should be run with a prewarmed pool of size 50. They should be fully allocated.
34 assert(EM_ASM_INT(return PThread.unusedWorkers.length) == 50);
35
36 double total = 0;
37 for (int i = 0; i < 10; ++i) {
38 double t1 = emscripten_get_now();
39 for (int j = 0; j < 50; ++j) {
40 CreateThread(j);
41 }
42 double t2 = emscripten_get_now();
43 printf("Took %f ms to allocate 50 threads.\n", t2 - t1);
44 total += (t2 - t1);
45 // Join all the threads to clear the queue..
46 for (int j = 0; j < 50; ++j) {
47 JoinThread(j);
48 }
49 }
50
51 printf("Final average %f ms.\n", total / 10.0);
52 return 0;
53}

Callers

nothing calls this directly

Calls 4

printfFunction · 0.85
JoinThreadFunction · 0.85
CreateThreadFunction · 0.70
emscripten_get_nowFunction · 0.50

Tested by

no test coverage detected