Home | Libraries | People | FAQ | More |
Fixes:
New Features:
Fixes:
Cleanup:
Features:
windows.h
file is included or not).
Implementation:
Fixes:
Test:
Doc:
See N2661 - A Foundation to Sleep On which is very informative and provides motivation for key design decisions. This section contains some extracts from this document.
This operator is convenient for computing where in a time frame a given duration lies. A motivating example is converting a duration into a "broken-down" time duration such as hours::minutes::seconds:
class ClockTime { typedef boost::chrono::hours hours; typedef boost::chrono::minutes minutes; typedef boost::chrono::seconds seconds; public: hours hours_; minutes minutes_; seconds seconds_; template <class Rep, class Period> explicit ClockTime(const boost::chrono::duration<Rep, Period>& d) : hours_ (boost::chrono::duration_cast<hours> (d)), minutes_(boost::chrono::duration_cast<minutes>(d % hours(1))), seconds_(boost::chrono::duration_cast<seconds>(d % minutes(1))) {} };
The following table presents a resume of which API is uused for each clock on each platform
Table 4.3. Clock API correspondence
Clock |
Windows Platform |
Posix Platform |
Mac Platform |
---|---|---|---|
GetSystemTimeAsFileTime |
clock_gettime( CLOCK_REALTIME) |
gettimeofday |
|
QueryPerformanceCounter and QueryPerformanceFrequency |
clock_gettime( CLOCK_STEADY) |
mach_timebase_info,mach_absolute_time |
|
GetProcessTimes |
times |
times |
|
GetProcessTimes |
times |
times |
|
GetProcessTimes |
times |
times |
|
GetProcessTimes |
times |
times |
|
GetThreadTimes |
clock_gettime(pthread_getcpuclockid) |
clock_gettime(pthread_getcpuclockid) |
Ask your operating system supplier. The results have been inspected with a debugger, and both for Windows and Linux, that's what the OS appears to be reporting at times.
Boost.Ratio avoids all kind of overflow that could result of arithmetic operation and that can be simplified. The typedefs durations don't detect overflow. You will need a duration representation that handles overflow.
Each clock has his own features. It depends on what do you need to benchmark. Most of the time, you could be interested in using a thread clock, but if you need to measure code subject to synchronization a process clock would be better. If you have a multi-process application, a system-wide clock could be needed.
For trace purposes, it is probably best to use a system-wide clock.
The library's code was derived from Howard Hinnant's time2_demo prototype. Many thanks to Howard for making his code available under the Boost license. The original code was modified by Beman Dawes to conform to Boost conventions.
time2_demo contained this comment:
Much thanks to Andrei Alexandrescu, Walter Brown, Peter Dimov, Jeff Garland, Terry Golubiewski, Daniel Krugler, Anthony Williams.
The file <boost/chrono_io.hpp> has been adapted from the experimental
header <chrono_io>
from Howard Hinnant. Thanks for all Howard.
Howard Hinnant, who is the real author of the library, has provided valuable
feedback and suggestions during the development of the library. In particular,
The chrono_io_io.hpp source has been adapted from the experimental header
<chrono_io>
from Howard Hinnant.
The acceptance review of Boost.Ratio took place between November 5th and 15th 2010. Many thanks to Anthony Williams, the review manager, and to all the reviewers: David Deakins, John Bytheway, Roland Bock and Paul A. Bristow.
Thanks to Ronald Bock, Andrew Chinoff, Paul A. Bristow and John Bytheway for his help polishing the documentation.
Thanks to Tom Tan for reporting some compiler issues with MSVC V10 beta and
MinGW-gcc-4.4.0 and for the many pushing for an homogeneous process_cpu_clock
clock.
Thanks to Ronald Bock for reporting Valgind issues and for the many suggestions he made concerning the documentation.
When BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED is defined the preceding deprecated functions are not available. In addition, the user needs to define the macro BOOST_CHRONO_IO_USES_EXTERNAL_LOCALIZATION to be able to customize the locale interface.