4 #include <darwintest.h>
11 T_META_NAMESPACE("xnu.perf"),
12 T_META_CHECK_LEAKS(false),
16 #define SPAWN_MEASURE_LOOP(s) \
17 char *args[] = {"/usr/bin/true", NULL}; \
21 while (!dt_stat_stable(s)) { \
23 err = posix_spawn(&pid, args[0], NULL, NULL, args, NULL); \
26 T_FAIL("posix_spawn returned %d", err); \
28 waitpid(pid, &status, 0); \
29 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
30 T_FAIL("Child process of posix_spawn failed to run"); \
34 T_DECL(posix_spawn_platform_binary_latency
, "posix_spawn platform binary latency") {
36 dt_stat_time_t s
= dt_stat_time_create("time");
37 SPAWN_MEASURE_LOOP(s
);
42 dt_stat_thread_cpu_time_t s
= dt_stat_thread_cpu_time_create("on_cpu_time");
43 SPAWN_MEASURE_LOOP(s
);
48 #define FORK_MEASURE_LOOP(s) \
51 while (!dt_stat_stable(s)) { \
57 T_FAIL("fork returned -1"); \
59 waitpid(pid, &status, 0); \
60 if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
61 T_FAIL("forked process failed to exit properly"); \
65 T_DECL(fork
, "fork latency") {
67 dt_stat_time_t s
= dt_stat_time_create("time");
72 dt_stat_thread_cpu_time_t s
= dt_stat_thread_cpu_time_create("on_cpu_time");