Currently, each TIMER implementation should implement a static now() method, which is used in the core of the benchmark loop in order to take time (or PMU or whatever other metric) snapshots before and after the code-under-test runs.
This is fine for timers that are "stateless" like rdtsc or clock_gettime or whatever, but it's kind of incompatible with ones like PerfTimer which set up state inside the timer object (in this case, representing the mmaped page for each configured counter), and so whose now() method in principle must be non-static. As a workaround for PerfTimer, it uses static (global) data which assumes there is only one PerfTimer object and otherwise violates all kinds of good coding principles.
We could just make this method non-static and rely on the compiler to optimize it "as if static" for implementations that don't actually need this. We'd also want to check the code quality for things like PerfTimer which use instance data. Other solutions are possible, such as passing the Timer object to a static now as a parameter (admittedly almost the same thing).
Currently, each
TIMER
implementation should implement a staticnow()
method, which is used in the core of the benchmark loop in order to take time (or PMU or whatever other metric) snapshots before and after the code-under-test runs.This is fine for timers that are "stateless" like
rdtsc
orclock_gettime
or whatever, but it's kind of incompatible with ones likePerfTimer
which set up state inside the timer object (in this case, representing themmap
ed page for each configured counter), and so whosenow()
method in principle must be non-static. As a workaround forPerfTimer
, it uses static (global) data which assumes there is only onePerfTimer
object and otherwise violates all kinds of good coding principles.We could just make this method non-static and rely on the compiler to optimize it "as if static" for implementations that don't actually need
this
. We'd also want to check the code quality for things likePerfTimer
which use instance data. Other solutions are possible, such as passing the Timer object to a staticnow
as a parameter (admittedly almost the same thing).