-
Notifications
You must be signed in to change notification settings - Fork 503
Use clock_gettime instead of clock for benchmarks #126
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
Use clock_gettime instead of clock for benchmarks #126
Conversation
src/apps/applib/include/benchmark.h
Outdated
BODY; \ | ||
} \ | ||
END_TIMER(duration); \ | ||
printf("\t-- %s: %Le ns per iteration (%d iterations)\n", name, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the formatting for nanoseconds here? In the example you posted on #125 I find it really hard to easily see order-of-magnitude differences. I'd prefer to still express this in ms, or maybe translate this to ops/second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that. I was considering working out a way to change the unit dynamically.
src/apps/applib/include/benchmark.h
Outdated
elapsed.tv_sec--; \ | ||
elapsed.tv_nsec = 1E9 + elapsed.tv_nsec; \ | ||
} \ | ||
const long double var = elapsed.tv_sec * 1E9 + elapsed.tv_nsec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still looks like nanoseconds. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow good catch. I must have forgotten about the final conversion back to microseconds.
src/apps/applib/include/benchmark.h
Outdated
elapsed.tv_sec--; \ | ||
elapsed.tv_nsec = 1E9 + elapsed.tv_nsec; \ | ||
} \ | ||
const long double var = (elapsed.tv_sec * 1E9 + elapsed.tv_nsec) / 1E3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add named constants for these scaling factors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought that might be more straightforward, just got a bit verbose. Let me post the diff and you can tell me your opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, makes it clearer what the units are
Use clock_gettime instead of clock for benchmarks
No description provided.