#define _POSIX_C_SOURCE 200809L #include #include #include #include #include #define N 4096 #define ITERS UINT64_C(2000000) static uint32_t seed = 0x53435350U; static uint32_t base_seed(void) { const char *v = getenv("SLEELA_BENCH_SEED"); return v ? (uint32_t)strtoul(v, NULL, 0) : 0x53435350U; } static uint32_t next_u32(void) { seed ^= seed << 13; seed ^= seed >> 17; seed ^= seed << 5; return seed; } static uint64_t now_ns(void) { struct timespec t; if (clock_gettime(CLOCK_MONOTONIC, &t)) return 0; return (uint64_t)t.tv_sec*1000000000ULL+(uint64_t)t.tv_nsec; } #define BENCH_INT(T, TAG, MASK, SIGNED_CAST) \ static void bench_##TAG(const char *op, T *a, T *b) { \ uint64_t start=now_ns(), sum=0; \ for (uint64_t i=0;i