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