TIMING(3)
π lmbench timing(3) β the lmbench timing subsystem π
okay bestie, sit DOWN, because we're about to talk about timing(3) from lmbench, and this one is literally the backbone of the whole vibe. no cap.
β¨ NAME β¨
benchmp, benchmp_getstate, benchmp_interval, start, stop, get_n, set_n, gettime, settime, get_enough, t_overhead, l_overhead β that's the whole lmbench timing subsystem, all of it, together, one big happy family π«Ά
πΈ SYNOPSIS πΈ
#include
typedef u_long iter_t;
typedef (*bench_f)(iter_t iterations, void* cookie);
typedef (*support_f)(iter_t iterations, void* cookie);
void benchmp(support_f initialize, bench_f benchmark, support_f cleanup,
int enough, int parallel, int warmup, int repetitions, void* cookie);
void* benchmp_getstate();
iter_t benchmp_interval(void* state);
void start(struct timeval *begin);
uint64 stop(struct timeval *begin, struct timeval *end);
uint64 get_n();
void set_n(uint64 n);
uint64 gettime();
void settime(uint64 u);
uint64 get_enough(uint64 enough);
uint64 t_overhead();
double l_overhead();
π¦ DESCRIPTION π¦
okay so real talk: the single most important element of a good benchmarking system is the quality and reliability of its measurement system. that's not me being dramatic, that's just facts π lmbench's timing subsystem manages the experimental timing process so you get accurate results in the least possible time. and it comes with methods for measuring and eliminating several factors that mess with the accuracy of timing measurements β like, for example, the resolution of the system clock. iconic behavior honestly.
lmbench gets accurate results by considering clock resolution, auto-sizing the duration of each benchmark, and conducting multiple experiments. three things. all of them matter. periodt.
π the functions, one by one π
void benchmp(initialize, benchmark, cleanup, enough, parallel, warmup, repetitions, cookie)β measures the performance ofbenchmarkrepeatedly and reports the median result.benchmpcreates parallel sub-processes which runbenchmarkin parallel, which is how lmbench measures the system's ability to scale as the number of client processes increases. each sub-process executesinitializebefore starting the benchmarking cycle, and it will callbenchmarkseveral times in order to collectrepetitionsresults. after all the benchmark results have been collected,cleanupis called to cleanup any resources which may have been allocated byinitializeorbenchmark. andcookieis avoidpointer to a hunk of memory that can be used to store any parameters or state that is needed by the benchmark. it's giving main character energy, honestly πvoid benchmp_getstate()β returns avoidpointer to the lmbench-internal state used during benchmarking. β οΈ the state is not to be used or accessed directly by clients, bestie, don't do it β instead it gets passed intobenchmp_interval.iter_t benchmp_interval(void* state)β returns the number of times the benchmark should execute its benchmark loop during this timing interval. this is used only for weird benchmarks which cannot implement the benchmark body in a function which can return, such as the page fault handler. please seelat_sig.cfor sample usage πvoid start(struct timeval *begin)β starts a timing interval. ifbeginis non-null, save the start time inbegin.uint64 stop(struct timeval *begin, struct timeval *end)β stops a timing interval, returning the number of elapsed micro-seconds.uint64 get_n()β returns the number of timesloop_bodywas executed during the timing interval.void set_n(uint64 n)β sets the number of timesloop_bodywas executed during the timing interval.uint64 gettime()β returns the number of micro-seconds in the timing interval.void settime(uint64 u)β sets the number of micro-seconds in the timing interval.uint64 get_enough(uint64 enough)β return the time in micro-seconds needed to accurately measure a timing interval.uint64 t_overhead()β return the time in micro-seconds needed to measure time.double l_overhead()β return the time in micro-seconds needed to do a simple loop.
π VARIABLES π
there are three environment variables that can be used to modify the lmbench timing subsystem: ENOUGH, TIMING_O, and LOOP_O. β¨
the environment variables can be used to directly set the results of get_enough, t_overhead, and l_overhead. when running a large number of benchmarks, or repeating the same benchmark many times, this can save time by eliminating the necessity of recalculating these values for each run. obsessed with the efficiency ngl π
β FUTURES β
Development of lmbench is continuing. (she's still growing, still evolving, still that girl π )
π SEE ALSO π
lmbench(8), lmbench(3), reporting(3), results(3).
π§ AUTHOR π§
Carl Staelin and Larry McVoy
Comments, suggestions, and bug reports are always welcome. (fr fr, they mean it, slide into their mentions π«Ά)
and that's the whole page bestie!(c)1998 Larry McVoy,$Date:$, from the lmbench timing(3) page. go forth and benchmark accurately, you absolute icon πΈπβ¨
π¦ where this page comes from
- debian bookworm: lmbench 3.0-a9+debian.1-6
- debian trixie: lmbench 3.0-a9+debian.1-9
- ubuntu jammy: lmbench 3.0-a9+debian.1-6
- ubuntu noble: lmbench 3.0-a9+debian.1-6build3
- ubuntu questing: lmbench 3.0-a9+debian.1-9
- ubuntu resolute: lmbench 3.0-a9+debian.1-10
- ubuntu stonking: lmbench 3.0-a9+debian.1-10
- Copyright (C) 1998 Carl Staelin and Larry McVoy
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms