Note that there are some explanatory texts on larger screens.

plurals
  1. POextending the std::chrono functionality to deal with run-time (non compile-time) constant periods
    primarykey
    data
    text
    <p>I have been experimenting with all kind of timers on Linux and OSX, and would like to try and wrap some of them with the same interface used by std::chrono.</p> <p>That's easy to do for timers that have a well-defined "period" at compile time, e.g. the POSIX clock_gettime() familiy, the clock_get_time() family on OSX, or gettimeofday().</p> <p>However, there are some useful timers for which the "period" - while constant - is only known at runtime. For example: - POSIX states the period of clock(), CLOCKS_PER_SEC, may be a variable on non-XSI systems - on Linux, the period of times() is given at runtime by sysconf(_SC_CLK_TCK) - on OSX, the period of mach_absolute_time() is given at runtime by mach_timebase_info() - on recent Intel processors, the DST register ticks at a constant rate, but of course that can only be determined at runtime</p> <p>To wrap these timers in the std::chrono interface, one possibility would be to use a period of std::chrono::nanosecond , and convert the value of each timer to nanoseconds. An other approach could be to use a floating point representation. However, both approaches would introduce a (very small) overhead to the now() function, and a (probably small) loss in precision.</p> <p>The solution I'm trying to pursue is to define a set of classes to represent such "run-time constant" periods, built along the same lines as the std::ratio class. However I expect that will require rewriting all the related template classes and functions (as they assume constexpr values).</p> <p>Does anyone have any experience with wrapping these kind of timers a la std:chrono ?</p> <p>Or with using non-constexpr values for the time period of a clock ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload