xref: /xnu-8792.41.9/tests/mpsc.c (revision 5c2921b07a2480ab43ec66f5b9e41cb872bc554f)
1*5c2921b0SApple OSS Distributions /*
2*5c2921b0SApple OSS Distributions  * mpsc: test the MPSC interface
3*5c2921b0SApple OSS Distributions  */
4*5c2921b0SApple OSS Distributions 
5*5c2921b0SApple OSS Distributions #ifdef T_NAMESPACE
6*5c2921b0SApple OSS Distributions #undef T_NAMESPACE
7*5c2921b0SApple OSS Distributions #endif
8*5c2921b0SApple OSS Distributions 
9*5c2921b0SApple OSS Distributions #include <darwintest.h>
10*5c2921b0SApple OSS Distributions #include <sys/sysctl.h>
11*5c2921b0SApple OSS Distributions 
12*5c2921b0SApple OSS Distributions T_GLOBAL_META(T_META_NAMESPACE("xnu.mpsc"),
13*5c2921b0SApple OSS Distributions     T_META_RUN_CONCURRENTLY(true));
14*5c2921b0SApple OSS Distributions 
15*5c2921b0SApple OSS Distributions T_DECL(pingpong, "mpsc_pingpong", T_META_ASROOT(true))
16*5c2921b0SApple OSS Distributions {
17*5c2921b0SApple OSS Distributions 	uint64_t count = 100 * 1000, nsecs = 0;
18*5c2921b0SApple OSS Distributions 	size_t nlen = sizeof(nsecs);
19*5c2921b0SApple OSS Distributions 	int error;
20*5c2921b0SApple OSS Distributions 
21*5c2921b0SApple OSS Distributions 	error = sysctlbyname("kern.mpsc_test_pingpong", &nsecs, &nlen,
22*5c2921b0SApple OSS Distributions 	    &count, sizeof(count));
23*5c2921b0SApple OSS Distributions 	T_ASSERT_POSIX_SUCCESS(error, "sysctlbyname");
24*5c2921b0SApple OSS Distributions 	T_LOG("%lld asyncs in %lld ns (%g us/async)", count, nsecs,
25*5c2921b0SApple OSS Distributions 	    (nsecs / 1e3) / count);
26*5c2921b0SApple OSS Distributions }
27