// Timing and RSS helpers for the benchmark. // // Allocation profiling is handled by heaptrack (an external LD_PRELOAD // tool), not by interposing malloc in this target. This avoids fragile // glibc-version-dependent hook code and the measurement perturbation of // in-process counting. #include "include/CBenchSupport.h" #include #include uint64_t bench_rss_kb(void) { FILE *f = fopen("/proc/self/statm", "r"); if (f == NULL) { return 0; } unsigned long total = 0, resident = 0; int n = fscanf(f, "%lu %lu", &total, &resident); fclose(f); if (n != 2) { return 0; } return (uint64_t)resident * 4; // pages -> KiB, assuming 4 KiB pages } uint64_t bench_now_ns(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (uint64_t)ts.tv_sec * 1000000000ull + (uint64_t)ts.tv_nsec; }