| 25 | } |
| 26 | |
| 27 | static void |
| 28 | test_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 | |
| 55 | static void |
| 56 | test_unhooked(int iters) { |
no test coverage detected