Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Description

The Boost.Chrono library provides:

Standard
Other clocks

To make the timing facilities more generally useful, Boost.Chrono provides a number of clocks that are thin wrappers around the operating system's time APIs, thereby allowing the extraction of wall clock time, user CPU time, system CPU time spent by the process,

Lastly, Boost.Chrono includes typeof registration for duration and time_point to permit using emulated auto with C++03 compilers.

I/O

It provides I/O for duration and time_point. This I/O makes use of these types much more convenient. In following the "you only pay for what you use" philosophy, this extra functionality is located in a header separate from <boost/chrono/chrono.hpp>, namely <boost/chrono/chrono_io.hpp>.

It builds on <boost/ratio/ratio_io.hpp> to provide readable and flexible formatting and parsing for types in <boost/chrono.hpp>. This textural representation uses SI prefixes whenever possible. This makes it easy for boost::milliseconds to be represented by the text "milliseconds", or a hypothetical meter class to print out "millimeter". The duration and the time_point i/o can be customized through the new facets: duration_units and time_point_units. The user can specialize these facets so that the chrono i/o could be localizable. However Boost.Chrono doesn't provides a complete locale solution.

system_clock::time_point I/O is proposed in terms of UTC timepoints, strongly guided by ISO 9899:1999, Programming languages - C, ISO 9945:2003, Information Technology - Portable Operating System Interface (POSIX) and ISO 8601:2004, Data elements and interchange formats - Information interchange - Representation of dates and times.

Rounding utilities

A few simple rounding utility functions for working with durations.

Caveat Emptor

The underlying clocks provided by operating systems are subject to many seemingly arbitrary policies and implementation irregularities. That's a polite way of saying they tend to be flakey, and each operating system or even each clock has its own cruel and unusual forms of flakiness. Don't bet the farm on their accuracy, unless you have become deeply familiar with exactly what the specific operating system is guaranteeing, which is often very little.


PrevUpHomeNext