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

Function test_hooked

deps/jemalloc/test/stress/hookbench.c:27–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27static void
28test_hooked(int iters) {
29 hooks_t hooks = {&noop_alloc_hook, &noop_dalloc_hook, &noop_expand_hook,
30 NULL};
31
32 int err;
33 void *handles[HOOK_MAX];
34 size_t sz = sizeof(handles[0]);
35
36 for (int i = 0; i < HOOK_MAX; i++) {
37 err = mallctl("experimental.hooks.install", &handles[i],
38 &sz, &hooks, sizeof(hooks));
39 assert(err == 0);
40
41 timedelta_t timer;
42 timer_start(&timer);
43 malloc_free_loop(iters);
44 timer_stop(&timer);
45 malloc_printf("With %d hook%s: %"FMTu64"us\n", i + 1,
46 i + 1 == 1 ? "" : "s", timer_usec(&timer));
47 }
48 for (int i = 0; i < HOOK_MAX; i++) {
49 err = mallctl("experimental.hooks.remove", NULL, NULL,
50 &handles[i], sizeof(handles[i]));
51 assert(err == 0);
52 }
53}
54
55static void
56test_unhooked(int iters) {

Callers 1

mainFunction · 0.85

Calls 5

malloc_free_loopFunction · 0.85
timer_startFunction · 0.50
timer_stopFunction · 0.50
malloc_printfFunction · 0.50
timer_usecFunction · 0.50

Tested by

no test coverage detected