4 #include <darwintest.h>
11 T_META_NAMESPACE("xnu.perf.fork"),
12 T_META_CHECK_LEAKS(false)
15 #define SPAWN_MEASURE_LOOP(s) \
16 char *args[] = {"/usr/bin/true", NULL}; \
20 while (!dt_stat_stable(s)) { \
22 err = posix_spawn(&pid, args[0], NULL, NULL, args, NULL); \
25 T_FAIL("posix_spawn returned %d", err); \
27 waitpid(pid, &status, 0); \
28 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
29 T_FAIL("Child process of posix_spawn failed to run"); \
33 T_DECL(posix_spawn_platform_binary_latency
, "posix_spawn platform binary latency") {
35 dt_stat_time_t s
= dt_stat_time_create("time");
36 SPAWN_MEASURE_LOOP(s
);
41 dt_stat_thread_cpu_time_t s
= dt_stat_thread_cpu_time_create("on-cpu time");
42 SPAWN_MEASURE_LOOP(s
);
47 #define FORK_MEASURE_LOOP(s) \
50 while (!dt_stat_stable(s)) { \
56 T_FAIL("fork returned -1"); \
58 waitpid(pid, &status, 0); \
59 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
60 T_FAIL("forked process failed to exit properly"); \
64 T_DECL(fork
, "fork latency") {
66 dt_stat_time_t s
= dt_stat_time_create("time");
71 dt_stat_thread_cpu_time_t s
= dt_stat_thread_cpu_time_create("on-cpu time");