/* * bench_strlen.c — how fast is our string core? * * Measures strlen() over a typical short string. 10M iterations keeps * the loop overhead negligible; results are printed as ns per call. */ #include #include "bench.h" #define ITERS 10000000UL int main(void) { static const char s[] = "the quick brown fox jumps over the lazy dog"; volatile size_t sink = 0; long long t0, t1; t0 = bench_now_ns(); for (unsigned long i = 0; i < ITERS; i++) sink += strlen(s); t1 = bench_now_ns(); (void)sink; /* keep the loop observable */ bench_print_u64((unsigned long long)((t1 - t0) / ITERS)); return 0; }