1 #include <darwintest.h>
7 #define SPAWN_MEASURE_LOOP(s) \
8 char *args[] = {"/usr/bin/true", NULL}; \
12 while (!dt_stat_stable(s)) { \
14 err = posix_spawn(&pid, args[0], NULL, NULL, args, NULL); \
17 T_FAIL("posix_spawn returned %d", err); \
19 waitpid(pid, &status, 0); \
20 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
21 T_FAIL("Child process of posix_spawn failed to run"); \
25 T_DECL(posix_spawn_platform_binary_latency
, "posix_spawn platform binary latency", T_META_TYPE_PERF
, T_META_CHECK_LEAKS(NO
)) {
27 dt_stat_time_t s
= dt_stat_time_create("time");
28 SPAWN_MEASURE_LOOP(s
);
33 dt_stat_thread_cpu_time_t s
= dt_stat_thread_cpu_time_create("on-cpu time");
34 SPAWN_MEASURE_LOOP(s
);
39 #define FORK_MEASURE_LOOP(s) \
42 while (!dt_stat_stable(s)) { \
48 T_FAIL("fork returned -1"); \
50 waitpid(pid, &status, 0); \
51 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
52 T_FAIL("forked process failed to exit properly"); \
56 T_DECL(fork
, "fork latency", T_META_TYPE_PERF
, T_META_CHECK_LEAKS(NO
)) {
58 dt_stat_time_t s
= dt_stat_time_create("time");
63 dt_stat_thread_cpu_time_t s
= dt_stat_thread_cpu_time_create("on-cpu time");