/* * bench_syscall.c — raw syscall round-trip cost. * * This is the number that justifies the whole project: for a kernel-first * libc (project guideline #6), every wrapper is one `syscall` instruction * away from the kernel. getpid() is the cheapest syscall there is, so * this measures the floor. 1M iterations; results in ns per call. */ #include #include "bench.h" #define ITERS 1000000UL int main(void) { volatile pid_t sink = 0; long long t0, t1; t0 = bench_now_ns(); for (unsigned long i = 0; i < ITERS; i++) sink += getpid(); t1 = bench_now_ns(); (void)sink; bench_print_u64((unsigned long long)((t1 - t0) / ITERS)); return 0; }