Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider making TimerInfo::now() non-static #62

Open
travisdowns opened this issue Sep 23, 2018 · 0 comments
Open

Consider making TimerInfo::now() non-static #62

travisdowns opened this issue Sep 23, 2018 · 0 comments

Comments

@travisdowns
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant