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