Loading...
tests/perf_spawn_fork.c xnu-12377.121.6 /dev/null
--- xnu/xnu-12377.121.6/tests/perf_spawn_fork.c
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifdef T_NAMESPACE
-#undef T_NAMESPACE
-#endif
-#include <darwintest.h>
-
-#include <spawn.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-T_GLOBAL_META(
-	T_META_NAMESPACE("xnu.perf"),
-	T_META_CHECK_LEAKS(false),
-	T_META_TAG_PERF
-	);
-
-#define SPAWN_MEASURE_LOOP(s) \
-	char *args[] = {"/usr/bin/true", NULL}; \
-	int err; \
-	pid_t pid; \
-	int status; \
-	while (!dt_stat_stable(s)) { \
-	        T_STAT_MEASURE(s) { \
-	                err = posix_spawn(&pid, args[0], NULL, NULL, args, NULL); \
-	        } \
-	        if (err) { \
-	                T_FAIL("posix_spawn returned %d", err); \
-	        } \
-	        waitpid(pid, &status, 0); \
-	        if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
-	                T_FAIL("Child process of posix_spawn failed to run"); \
-	        } \
-	}
-
-T_DECL(posix_spawn_platform_binary_latency, "posix_spawn platform binary latency", T_META_TAG_VM_NOT_ELIGIBLE) {
-	{
-		dt_stat_time_t s = dt_stat_time_create("time");
-		SPAWN_MEASURE_LOOP(s);
-		dt_stat_finalize(s);
-	}
-
-	{
-		dt_stat_thread_cpu_time_t s = dt_stat_thread_cpu_time_create("on_cpu_time");
-		SPAWN_MEASURE_LOOP(s);
-		dt_stat_finalize(s);
-	}
-}
-
-#define FORK_MEASURE_LOOP(s) \
-	pid_t pid; \
-	int status; \
-	while (!dt_stat_stable(s)) { \
-	        T_STAT_MEASURE(s) { \
-	                pid = fork(); \
-	                if (pid == 0) \
-	                        exit(0); \
-	                else if (pid == -1) \
-	                        T_FAIL("fork returned -1"); \
-	        } \
-	        waitpid(pid, &status, 0); \
-	        if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { \
-	                T_FAIL("forked process failed to exit properly"); \
-	        } \
-	}
-
-T_DECL(fork, "fork latency", T_META_TAG_VM_NOT_ELIGIBLE) {
-	{
-		dt_stat_time_t s = dt_stat_time_create("time");
-		FORK_MEASURE_LOOP(s);
-		dt_stat_finalize(s);
-	}
-	{
-		dt_stat_thread_cpu_time_t s = dt_stat_thread_cpu_time_create("on_cpu_time");
-		FORK_MEASURE_LOOP(s);
-		dt_stat_finalize(s);
-	}
-}