benchmark.cc is using non portable high precision timer #259
Comments
|
Wouldn't |
|
I like the clock() / CLOCKS_PER_SEC approach. The reason I didn't use it originally was:
But reading the spec for clock(), it seems like it's processor time for this process only, and on modern systems gives microsecond resolution. And considering that I can't seem to get numbers more accurate than about +-200ms on my laptop because of Turbo Boost, I think that the desire for more accuracy may not be worth it, particularly at the cost of portability. |
|
Reproduced on Travis CI, the pull request fixed it. |
|
|
Currently benchmark.cc is calling clock_gettime with CLOCK_PROCESS_CPUTIME_ID as the first parameter.
This is not available in Mac OSX (or windows AFAIK), and results in failure to compile.
I'm considering sending a pull request, but am not sure how exactly to fix this.
Using #ifdefs to handle different platforms is something I tend to avoid at all costs.
Considering c++11 is an option here, using std::chrono::high_resolution_timer could help, but that should measure wall time and not cpu time.
std::clock could be a cross platform way to implement this, but seems to have less resolution than clock_gettime with CLOCK_PROCESS_CPUTIME_ID.
The text was updated successfully, but these errors were encountered: