Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80426 - in trunk/libs/chrono/doc: . stopwatches
From: vicente.botet_at_[hidden]
Date: 2012-09-06 19:53:26


Author: viboes
Date: 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
New Revision: 80426
URL: http://svn.boost.org/trac/boost/changeset/80426

Log:
Chrono: Extract stopwatches doc on specific files
Added:
   trunk/libs/chrono/doc/stopwatches/
   trunk/libs/chrono/doc/stopwatches/description.qbk (contents, props changed)
   trunk/libs/chrono/doc/stopwatches/hello.qbk (contents, props changed)
   trunk/libs/chrono/doc/stopwatches/motivation.qbk (contents, props changed)
   trunk/libs/chrono/doc/stopwatches/reference.qbk (contents, props changed)
   trunk/libs/chrono/doc/stopwatches/tutorial.qbk (contents, props changed)
Text files modified:
   trunk/libs/chrono/doc/chrono.qbk | 1963 +--------------------------------------
   1 files changed, 61 insertions(+), 1902 deletions(-)

Modified: trunk/libs/chrono/doc/chrono.qbk
==============================================================================
--- trunk/libs/chrono/doc/chrono.qbk (original)
+++ trunk/libs/chrono/doc/chrono.qbk 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
@@ -15,7 +15,7 @@
     [authors [Botet Escriba, Vicente J.]]
     [copyright 2008 Howard Hinnant]
     [copyright 2006, 2008 Beman Dawes]
- [copyright 2009-2011 Vicente J. Botet Escriba]
+ [copyright 2009-2012 Vicente J. Botet Escriba]
     [category utilities system]
     [id chrono]
     [dirname chrono]
@@ -29,7 +29,6 @@
     ]
 ]
 
-
 [/==================]
 [def __Boost_Chrono__ [*Boost.Chrono]]
 [def __Boost_Chrono [*Boost.Chrono]]
@@ -316,7 +315,7 @@
 [def __duration_units_d [link chrono.reference.io.duration_units_hpp.duration_units.d `~duration_units`]]
 [def __duration_units_get_n_d_valid_units_start [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_valid_units_start `get_n_d_valid_units_start`]]
 [def __duration_units_get_n_d_valid_units_end [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_valid_units_end `get_n_d_valid_units_end`]]
-[def __duration_units_get_n_d_unit [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_valid_unit `get_n_d_unit`]]
+[def __duration_units_get_n_d_unit [link chrono.reference.io.duration_units_hpp.duration_units.get_n_d_unit `get_n_d_unit`]]
 [def __duration_units_do_get_n_d_unit [link chrono.reference.io.duration_units_hpp.duration_units.do_get_n_d_unit `do_get_n_d_unit`]]
 [def __duration_units_match_n_d_valid_unit [link chrono.reference.io.duration_units_hpp.duration_units.match_n_d_valid_unit `match_n_d_valid_unit`]]
 [def __duration_units_get_valid_units_start [link chrono.reference.io.duration_units_hpp.duration_units.get_valid_units_start `get_valid_units_start`]]
@@ -359,23 +358,23 @@
 
 [/==================]
 
-[def __StrictStopwatch [link chrono.reference.stopwatches.strict_stopwatch_req `StrictStopwatch`]]
-[def __strict_stopwatch_concept [link chrono.reference.stopwatches.strict_stopwatch_req `StrictStopwatch`]]
-[def __strict_stopwatch [link chrono.reference.stopwatches.strict_stopwatch_hpp.strict_stopwatch `strict_stopwatch`]]
-
-
-[def __strict_stopclock [link chrono.reference.stopwatches.strict_stopclock_hpp.strict_stopclock `strict_stopclock`]]
-
-[def __Stopwatch [link chrono.reference.stopwatches.stopwatch_req `Stopwatch`]]
-[def __stopwatch_concept [link chrono.reference.stopwatches.stopwatch_req `Stopwatch`]]
-[def __stopwatch [link chrono.reference.stopwatches.stopwatch_hpp.stopwatch `stopwatch`]]
-[def __laps_stopwatch [link chrono.reference.stopwatches.stopwatch_hpp.stopwatch `laps_stopwatch`]]
-[def __laps_stopclock [link chrono.reference.stopwatches.stopwatch_hpp.stopwatch `basic_stopclock`]]
-
-[def __SuspendableStopwatch [link chrono.reference.stopwatches.suspendable_stopwatch_req `SuspendableStopwatch`]]
-[def __suspendable_stopwatch_concept [link chrono.reference.stopwatches.suspendable_stopwatch_req `SuspendableStopwatch`]]
-[def __suspendable_stopwatch [link chrono.reference.stopwatches.suspendable_stopwatch_hpp.suspendable_stopwatch `suspendable_stopwatch`]]
-[def __suspendable_stopclock [link chrono.reference.stopwatches.suspendable_stopwatch_hpp.suspendable_stopwatch `suspendable_stopclock`]]
+[def __StrictStopwatch [link boost_chrono.reference.stopwatches.strict_stopwatch_req `StrictStopwatch`]]
+[def __strict_stopwatch_concept [link boost_chrono.reference.stopwatches.strict_stopwatch_req `StrictStopwatch`]]
+[def __strict_stopwatch [link boost_chrono.reference.stopwatches.strict_stopwatch_hpp.strict_stopwatch `strict_stopwatch`]]
+
+
+[def __strict_stopclock [link boost_chrono.reference.stopclocks.strict_stopclock_hpp.strict_stopclock `strict_stopclock`]]
+
+[def __Stopwatch [link boost_chrono.reference.stopwatches.stopwatch_req `Stopwatch`]]
+[def __stopwatch_concept [link boost_chrono.reference.stopwatches.stopwatch_req `Stopwatch`]]
+[def __stopwatch [link boost_chrono.reference.stopwatches.stopwatch_hpp.stopwatch `stopwatch`]]
+[def __laps_stopwatch [link boost_chrono.reference.stopwatches.stopwatch_hpp.stopwatch `laps_stopwatch`]]
+[def __laps_stopclock [link boost_chrono.reference.stopwatches.stopwatch_hpp.stopwatch `basic_stopclock`]]
+
+[def __SuspendableStopwatch [link boost_chrono.reference.stopwatches.suspendable_stopwatch_req `SuspendableStopwatch`]]
+[def __suspendable_stopwatch_concept [link boost_chrono.reference.stopwatches.suspendable_stopwatch_req `SuspendableStopwatch`]]
+[def __suspendable_stopwatch [link boost_chrono.reference.stopwatches.suspendable_stopwatch_hpp.suspendable_stopwatch `suspendable_stopwatch`]]
+[def __suspendable_stopclock [link boost_chrono.reference.stopwatches.suspendable_stopwatch_hpp.suspendable_stopwatch `suspendable_stopclock`]]
 
 [def __stopwatch_reporter `stopwatch_reporter `]
 [def __stopclock `stopclock `]
@@ -459,36 +458,7 @@
 [/These clocks capture the specific time unitarily. __Boost_Chrono__ provides also a clock __process_cpu_clock that captures the three times at once.
 ]
 
-[heading Measuring elapsed time]
-
-Knowing how long a program, a function or a specific code block takes to execute is useful in both test and production environments.
-__Boost_Chrono introduces the __strict_stopwatch_concept concept which is a mechanism to measure the elapsed time.
-__strict_stopwatch`<>` is the basic model of __strict_stopwatch_concept.
-
-[heading Reporting elapsed time]
-
-It is often necessary to report elapsed time on a user display or in a log file. __stopwatch_reporter provides a runtime reporting mechanism for this purpose which can be invoked in just one line of code.
-
- using namespace boost::chrono;
- int main()
- {
- __stopwatch_reporter<__stopwatch<__process_cpu_clocks> > _;
- // ...
- }
-
-Will produce the following output
-
- real 0.034s, cpu 0.031s (93.0%), user 0.031s, system 0.000s
-
-As this is one of the expression more commonly use, the library provides a __stopclock shortcut so the preceding can be written as
-
- int main()
- {
- __stopclock<__process_cpu_clocks> _;
- // ...
- }
-
-
+[include stopwatches/motivation.qbk]
 
 [endsect]
 
@@ -540,25 +510,7 @@
 
 A few simple rounding utility functions for working with durations.
 
-[heading Stopwatch/Stopclocks framework]
-
-On top of the core facilities, __Boost_Chrono provides:
-
-Stopwatches: Some facility to measure elapsed time with the ability to start, stop, suspend, or resume measurement.
-
-* __StrictStopwatch, __Stopwatch, __SuspendableStopwatch concepts.
-* __strict_stopwatch, model of __StrictStopwatch capturing elapsed __Clock times.
-* __laps_stopwatch, model of __Stopwatch allowing in addition to start and stop the capture of elapsed __Clock times.
-* __suspendable_stopwatch, model of __SuspendableStopwatch allowing in addition to suspend and resume the capture of elapsed __Clock times.
-* __laps_stopwatch and __suspendable_stopwatch have __LapsCollector template parameter that allows to store information of the samples defined by a cycle start-stop.
-
-Stopclocks: a complete time reporting package that can be invoked in a single line of code.
-
-* __stopwatch_reporter`<__Stopwatch,__Formatter>`, convenient reporting to an output stream (including wide char streams) of the elapsed time of models of __Stopwatch results.
-* Some basic __Formatters.
-* `__strict_stopclock<__Clock>` shortcut of `__stopwatch_reporter<__strict_stopwatch<__Clock>>`
-* `__stopclock<__Clock>` shortcut of `__stopwatch_reporter<__stopwatch<__Clock>>`
-* `__suspendable_stopclock<__Clock>` shortcut of `__stopwatch_reporter<__suspendable_stopwatch<__Clock>>`
+[include stopwatches/description.qbk]
 
 [heading Caveat Emptor]
 
@@ -711,26 +663,30 @@
 [section Hello World! ]
 [/====================]
 
-If all you want to do is to time a program's execution, here is a complete program (stopclock_example.cpp):
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+If all you want to do is to time a program's execution, here is a complete program:
 
- #include <boost/chrono_io.hpp>
- #include <boost/chrono/stopwatches/reporters/stopclock.hpp>
+ #include <boost/chrono.hpp>
     #include <cmath>
 
     int main()
     {
- boost::chrono::system_strict_stopclock _;
+ boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now();
 
         for ( long i = 0; i < 10000000; ++i )
         std::sqrt( 123.456L ); // burn some time
 
+ boost::chrono::__duration<double> sec = boost::chrono::system_clock::now() - start;
+ std::cout << "took " << sec.count() << " seconds\n";
         return 0;
     }
 
 Output was:
 
- 0.832 seconds
+ took 0.832 seconds
 
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[include stopwatches/hello.qbk]
 
 [endsect]
 
@@ -1588,354 +1544,7 @@
 
 [endsect] [/ I/O]
 
-[section Stopwatches and Stopclocks]
-[/=================================]
-
-At the user level, the main use case of measuring the elapsed time is to report these measures on the display. For example
-
- using namespace boost::chrono;
-
- int f1(long j) {
- strict_stopwatch<> sw;
-
- for ( long i = 0; i < j; ++i )
- std::sqrt( 123.456L ); // burn some time
-
- std::cout << sw.elapsed() << std::endl;
- return 0;
- }
- int main() {
- f1(100000);
- f1(200000);
- f1(300000);
- return 0;
- }
-
-Could produce the following output
-
- 0.006s
- 0.011s
- 0.017s
-
-__stopwatch is a template class with a Clock as template parameter. The default __Clock is the __high_resolution_clock.
-
-We can replace the lines
-
- strict_stopwatch <> sw;
-
- ...
- std::cout << sw.elapsed() << std::endl;
-
-using the __stopwatch_reporter`<>` class. This class provides a run time reporting package that can be invoked in a single line of code to report the usage of a __Clock. For example
-
- using namespace boost::chrono;
-
- int f1(long j) {
- __stopwatch_reporter<__strict_stopwatch <> > _;
-
- for ( long i = 0; i < j; ++i )
- std::sqrt( 123.456L ); // burn some time
-
- return 0;
- }
- int main() {
- f1(100000);
- f1(200000);
- f1(300000);
- return 0;
- }
-
-Which produce the same kind of output.
-
-__stopwatch_reporter is a template class with a __Stopwatch and a __Formatter as template parameter.
-
-We can use even a shorter line using the __stopclock class, which allows to replace
-
- __stopwatch_reporter<__strict_stopwatch<> > _;
-
-by
-
- __strict_stopclock<> _;
-
-[section:accumulators Stopwatches accumulation and statistics]
-
-The preceding stopwatch manage only with a measure. It is also interesting to have an statisitical view of these times,
-for example the sum, min, max and mean. __laps_stopwatch`<>` associates an accumulator with a __stopwatch__, so we are able to retrieve any statistical feature Boost.Accumulator provides.
-
-For example
-
- using namespace boost::chrono;
-
- int f1(long j) {
- static __stopwatch_reporter<__laps_stopwatch<> > sw;
- __stopwatch_reporter<__laps_stopwatch<> >::scoped_run _(sw);
-
- for ( long i = 0; i < j; ++i )
- std::sqrt( 123.456L ); // burn some time
-
- return 0;
- }
- int main() {
- f1(100000);
- f1(200000);
- f1(300000);
- return 0;
- }
-
-Will produce the following output
-
- 3 times, sum=0.034s, min=0.006s, max=0.017s, mean=0.011s
-
-
-[endsect]
-
-
-
-[section:function How can I prefix each report with `BOOST_CURRENT_FUNCTION` function signature?]
-
-You will need to give a specific format to your __stopclock. You just need to concatenate your specific pattern to the default_format of the formatter.
-
-For example, for a __stopclock_accumulator the default formatter is __stopwatch_accumulator_formatter, you will need to do something like:
-
- static __stopclock_accumulator<> acc(
- std::string(BOOST_CURRENT_FUNCTION) + ": "
- + __stopwatch_accumulator_formatter::default_format()
- );
- __stopclock_accumulator<>::scoped_run _(acc);
-
-
-Some of you will say that this is too long to type just to get the a report. You can of course define your own macro as
-
- #define REPORT_FUNCTION_ACCUMULATED_LIFETIME\
- static boost::stopwatches::__stopclock_accumulator<> \
- BOOST_JOIN(_accumulator_, __LINE__)_
- ( std::string(BOOST_CURRENT_FUNCTION) + ": " + \
- boost::stopwatches::__stopwatch_accumulator_formatter::default_format() \
- ); \
- boost::stopwatches::__stopclock_accumulator<>::scoped_run \
- BOOST_JOIN(_accumulator_run_, __LINE__) \
- (BOOST_JOIN(_accumulator_, __LINE__))
-
-
-With this macro you will just have to write
-
- void foo()
- {
- REPORT_FUNCTION_ACCUMULATED_LIFETIME() ;
- boost::this_thread::sleep(boost::posix_time::milliseconds(100));
- // ...
- }
-
-[endsect]
-
-[section:file_line How can I prefix each report with `__FILE__[__LINE__]` pattern?]
-
-When you want to prefix with the `__FILE__[__LINE__]` pattern you can follow the same technique as described below:
-
- #define REPORT_LINE_ACCUMULATED_LIFETIME \
- static __stopclock_accumulator<>
- BOOST_JOIN(_accumulator_, __LINE__) \
- ( std::string(__FILE__) + "[" + BOOST_STRINGIZE(__LINE__) + "] "
- + __stopwatch_accumulator_formatter::default_format() \
- ); \
- __stopclock_accumulator<>::scoped_run \
- BOOST_JOIN(_accumulator_run_, __LINE__)
- (BOOST_JOIN(_accumulator_, __LINE__))
-
-Now you can mix fcntion and line reports as follows
-
- void foo()
- {
- REPORT_FUNCTION_ACCUMULATED_LIFETIME;
- boost::this_thread::sleep(boost::posix_time::milliseconds(100));
- {
- REPORT_LINE_ACCUMULATED_LIFETIME;
- boost::this_thread::sleep(boost::posix_time::milliseconds(200));
- }
-
- }
-
-[endsect]
-
-[section:non_static_acc Can I use an stopclock accumulator which is not static?]
-
-The typical example of stopclock_accumulator is to get statistical measures of the time a function takes for each one of its calls.
-You can also use __stopclock_accumulator to get statistical measures of the time a given loop takes for each one of its laps.
-
- __stopclock_accumulator<> acc(
- std::string(__FILE__) + "[" + BOOST_STRINGIZE(__LINE__) + "] "
- + __stopwatch_accumulator_formatter::default_format()
- );
- for (int i=0; i<N; i++) {
- __stopclock_accumulator<>::scoped_run _(acc);
- // ...
- }
-
-
-[endsect]
-
-[section:suspend How can I suspend a stopwatch?]
-
- #include <boost/stopwatches/stopwatch.hpp>
- #include <cmath>
- #include <boost/thread.hpp>
-
-
- using namespace boost::stopwatches;
- double res;
- void f1(long j)
- {
- __stopwatch_reporter<__stopwatch__<> >:: _(BOOST_STOPWATCHES_STOPWATCH_FUNCTION_FORMAT);
- for (long i =0; i< j; i+=1)
- res+=std::sqrt( res+123.456L+i ); // burn some time
- __stopwatch_reporter<__stopwatch__<> >::scoped_suspend s(_);
- boost::this_thread::sleep(boost::posix_time::milliseconds(200));
- }
-
-[endsect]
-
-[section:stats How to get specific statistics from stopwatches accumulator?]
-
-There are two use cases that coul need to change the statistics associated to a stopwatches accumulator:
-
-# We want to reduce the default reporting and we preffer to adapt the statistics to the reporting
-# We want to report other statistics of the samples
-
-For the first case we just need to change the accumulator_set and the format we want to get. Imagin we want to get only the count, sam and mean statistics, no need to calculate the min neither the max.
-
- using namespace boost::accumulators;
-
- typedef __stopwatch_reporter<__laps_stopwatch<__process_real_cpu_clock__,
- accumulator_set<__process_real_cpu_clock__::rep,
- features<
- tag::count,
- tag::sum,
- tag::mean
- >
- >
- > my_stopwatch_accumulator_reporter;
-
- int f1(long j)
- {
- static my_stopwatch_accumulator_reporter acc("%c times, sum=%ss, mean=%as\n");
- my_stopwatch_accumulator_reporter::scoped_run _(acc);
-
- for ( long i = 0; i < j; ++i )
- std::sqrt( 123.456L ); // burn some time
-
- return 0;
- }
-
-But what would hapend if we haven't forced the format:
-
- static my_stopwatch_accumulator_reporter acc;
- my_stopwatch_accumulator_reporter::scoped_run _(acc);
-
-Unfortunately there is no error at compile time. Fortunately, the run-time execution is not undefined and will return 0 for the missing statistics.
-
-
-[endsect]
-
-[section Formatting]
-
-[section:other How can I make a specific formatter when the default do not satisfy my expectations]
-
-Imagine then that we want to report the `tag::variance(lazy)`. We will need to include the specific accumulator file
-
- ...
- #include <boost/accumulators/statistics/variance.hpp>
- ...
- typedef __stopwatch_reporter<__laps_stopwatch<__process_real_cpu_clock__,
- accumulator_set<__process_real_cpu_clock__::rep,
- features<
- tag::count,
- tag::sum,
- tag::mean,
- tag::variance(lazy)
- >
- >
- > my_stopwatch_accumulator_reporter;
-
-But what happens if we add new statistics to the accumulator_set that are not taken in account by the default formatter? These statistics will simply be ignored. So we will need to define our own accumulator formatter.
-
- typedef __stopwatch_reporter<__laps_stopwatch<__process_real_cpu_clock__,
- accumulator_set<__process_real_cpu_clock__::rep,
- features<
- tag::count,
- tag::sum,
- tag::mean,
- tag::variance(lazy)
- >
- >,
- my_stopwatch_accumulator_formatter
- > my_stopwatch_accumulator_reporter;
-
-Next follow the definition of a formatter taking care of count, sum, mean and variance
-
- class my_stopwatch_accumulator_formatter {
- public:
- typedef std::string string_type;
- typedef char char_type;
- typedef std::ostream ostream_type;
-
- static ostream_type & default_os() {return std::cout;}
- static const char_type* default_format() {
- return "%c times, sum=%ss, mean=%as, variance=%vs\n";
- }
- static int default_places() { return 3; }
-
- template <class Stopwatch >
- static void show_time( Stopwatch & stopwatch_, const char_type* format,
- int places, ostream_type & os, system::error_code & ec)
- {
- typedef typename Stopwatch::duration duration_t;
- typename Stopwatch::accumulator accumulator& acc = stopwatch_.accumulated();
-
- boost::io::ios_flags_saver ifs( os );
- os.setf( std::ios_base::fixed, std::ios_base::floatfield );
- boost::io::ios_precision_saver ips( os );
- os.precision( places );
-
- for ( ; *format; ++format ) {
- if ( *format != '%' || !*(format+1) || !std::strchr("acsv", *(format+1)) ) {
- os << *format;
- } else {
- ++format;
- switch ( *format ) {
- case 's':
- os << boost::chrono::duration<double>(
- duration_t(accumulators::sum(acc))).count();
- break;
- case 'a':
- os << (accumulators::count(acc)>0)
- ? boost::chrono::__duration__<double>(duration_t(
- duration_t::rep(accumulators::mean(acc)))).count()
- : 0;
- break;
- case 'c':
- os << accumulators::count(acc);
- break;
- case 'v':
- os << (accumulators::count(acc)>0)
- ? boost::chrono::__duration__<double>(duration_t(
- duration_t::rep(accumulators::variance(acc)))).count()
- : 0;
- break;
- default:
- assert(0 && "my_stopwatch_accumulator_formatter internal logic error");
- }
- }
- }
- }
- };
-
-
-
-[endsect]
-
-
-[endsect]
-[endsect]
+[include stopwatches/tutorial.qbk]
 
 [endsect]
 [/===============]
@@ -2846,8 +2455,10 @@
     #include <boost/chrono/ceil.hpp>
     #include <boost/chrono/floor.hpp>
     #include <boost/chrono/round.hpp>
- #include <boost/chrono/stopwatches.hpp>
 
+[/ /////////////////////////////////////////////////////
+ #include <boost/chrono/stopwatches.hpp>
+] [////////////////////////////////////////////////////]
 [endsect]
 
 [section:cpp0x Included on the C++11 Recommendation]
@@ -4506,6 +4117,11 @@
         timezone __get_timezone(std::ios_base & ios);
         void __set_timezone(std::ios_base& ios, timezone tz);
         
+ template<typename CharT>
+ std::basic_string<CharT> __get_time_fmt(std::ios_base & ios);
+ template<typename CharT>
+ void __set_time_fmt(std::ios_base& ios, std::basic_string<CharT> const& fmt);
+
         // i/o state savers
         struct __duration_style_io_saver;
         template<typename CharT = char, typename Traits = std::char_traits<CharT> >
@@ -4529,7 +4145,7 @@
 
         void set_duration_style(std::ios_base& ios, duration_style style);
         
-__effects Set the stream's __duration_style attribute associated to `ios` so the `style` parameter.
+__effects Set the stream's __duration_style attribute associated to `ios` with the `style` parameter.
         
 [endsect]
 
@@ -4545,7 +4161,25 @@
 
         void set_timezone(std::ios_base& ios, timezone tz);
         
-__effects Set the stream's __timezone attribute associated to `ios` so the `style` parameter.
+__effects Set the stream's __timezone attribute associated to `ios` with the `tz` parameter.
+
+[endsect]
+
+[section:get_time_fmt Non Member Function `get_time_fmt(std::ios_base &)`]
+
+ template<typename CharT>
+ std::basic_string<CharT> __get_time_fmt(std::ios_base & ios);
+
+__returns The stream's time format attribute associated to `ios`.
+
+[endsect]
+
+[section:set_time_fmt Non Member Function `set_time_fmt(std::ios_base&, std::basic_string<CharT> const&)`]
+
+ template<typename CharT>
+ void __set_time_fmt(std::ios_base& ios, std::basic_string<CharT> const& fmt);
+
+__effects Set the stream's time format attribute associated to `ios` with the `fmt` parameter.
         
 [endsect]
 
@@ -6680,7 +6314,7 @@
 
 __effects Behaves as a formatted output function. After constructing a `sentry` object, if the `sentry` converts to
 `true`, sets a local variable `tz` of type __timezone to `get_timezone(os)`.
-Additionally the format string obtained with `get_time_fmt()` is recorded as a pair of `const CharT*`.
+Additionally the format string obtained with `__get_time_fmt()` is recorded as a pair of `const CharT*`.
 If the stream has no time_punct facet, then this pair of `const CharT*` that represent an empty range.
 
 Next `tp` is converted to a `time_t`, and this `time_t` is converted to a `tm`.
@@ -7347,1487 +6981,12 @@
 
 [endsect]
 
-
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatches Stopwatches]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:strict_stopwatch_req `StrictStopwatch` Requirements]
-
-A StrictStopwatch measure the amount of time elapsed from a start point in time.
-
-While __Clock are static and not instantiated, `StrictStopwatch` are instantiated and associated to a given __Clock.
-
-A `S` meets the `StrictStopwatch` requirements if:
-
-* `S::clock` meets the __Clock requirements, and
-* meets the requirements specified in the following table.
-
-In this table `S` denote a StrictStopwatch type. `sc` is an instance of `S` const.
-
-[table StrictStopwatch Requirements
- [[expression] [return type] [operational semantics]]
- [[`S::clock`] [A model of __Clock.] [The clock associated to this Stopwatch.]]
- [[`S::duration`] [`S::clock::duration`] [The __duration type of the `clock`.]]
- [[`S::time_point`] [`S::clock::time_point`] [The __time_point type of the `clock`.]]
- [[`S()`] [`S&&`] [Constructd a stopwatch.]]
- [[`sc.elapsed()`] [`S::duration`] [the elapsed time while the __StrictStopwatch was running.]]
-
-]
-
-
-[/ /////////////////////////////
-
-, `ec` is instance of `system::error_code`
-
- [[`S(ec)`] [`S&&`] [Constructd a stopwatch.]]
- [[`sc.elapsed(ec)`] [`S::duration`] [the elapsed time while the __StrictStopwatch was running.]]
-
-////////////////////////////// ]
-
-Models of `StrictStopwatch `:
-
-* __strict_stopwatch
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:elapsed `sc.elapsed()`]
-
-__return_type `S::duration`.
-
-__returns the elapsed time.
-
-[endsect]
-
-[/ /////////////////////////////
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:elapsed_ec `sc.elapsed(ec)`]
-
-__return_type `S::duration`.
-
-__returns the elapsed time or `S::duration::zero()` if an error occurred.
-
-__effects When there is an internal error stores the error code in the `ec` parameter`.
-
-[endsect]
-////////////////////////////// ]
-[endsect]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_req `Stopwatch` Requirements]
-
-As a __StrictStopwatch, a __Stopwatch measure the amount of time elapsed from a start point in time.
-The main difference is that a __Stopwatch can be started and stopped (and restarted).
-The duration between these two time points is called a lap. It could have in addition the capability to collect these lap samples.
-
-A `S` meets the `Stopwatch` requirements if:
-
-* `S` meets the __StrictStopwatch requirements, and
-* meets the requirements specified in the following table.
-
-In this table `S` denote `Stopwatch` type. `s` is an instance of `S`, `sc` is an instance of `S` const.
-
-[table Stopwatch Requirements
- [[expression] [return type] [operational semantics]]
- [[`S::laps_collector `] [ A model of __LapsCollector] [Collects the laps's samples.]]
- [[`S::scoped_run`] [`__stopwatch_runner<S>`] [RAI which `start`/`stop` the `stopwatch`.]]
- [[`S::scoped_stop`] [`__stopwatch_stopper<S>`] [RAI which `stop`/`start` the `stopwatch`.]]
-
- [[`S(dont_start)`] [`S&&`] [Constructd a stopwatch.]]
- [[`S(coll)`] [`S&&`] [Constructd a stopwatch.]]
-
- [[`s.start()`] [-] [starts a Stopwatch.]]
- [[`s.stop()`] [-] [stops a Stopwatch.]]
- [[`s.stop(ec)`] [-] [stops a Stopwatch.]]
- [[`s.restart()`] [-] [restarts a Stopwatch.]]
- [[`s.reset()`] [-] [Resets as if it was constructed again.]]
-
- [[`sc.is_running()`] [`bool`] [whether the stopwatch is running or not.]]
- [[`sc.elapsed_current_lap()`] [`S::duration`] [the elapsed time since the last start.]]
- [[`sc.is_running()`] [bool] [true if the Stopwatch is running.]]
- [[`sc.lap_collector()`] [`S::laps_collector const&`] [the elapsed time while the Stopwatch was running.]]
-
-]
-
-
-[/ /////////////////////////////
-
-`ec` is instance of `system::error_code`
-
- [[`S(coll,ec)`] [`S&&`] [Constructd a stopwatch.]]
- [[`s.start(ec)`] [-] [starts a Stopwatch.]]
- [[`s.restart(ec)`] [-] [restarts a Stopwatch.]]
- [[`s.reset(ec)`] [-] [Resets as if it was constructed again.]]
- [[`sc.elapsed_current_lap(ec)`] [`S::duration`] [the elapsed time since the last start.]]
-
-////////////////////////////// ]
-
-Models of `Stopwatch`:
-
-* __stopwatch
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:start `start()`]
-
-__effects Starts running the stopwatch.
-
-__throws Any exception the `S::clock::now()` function can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stop `stop()`]
-
-__effects Stops running the stopwatch.
-
-__throws Any exception the __LapsCollector can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:restart `restart()`]
-
-__effects `stop`/`start` the stopwatch.
-
-__throws Any exception the `S::clock::now` function can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:is_running `sc.is_running()`]
-
-__return_type `bool`.
-
-__returns Whether the stopwatch is running or not.
-
-__throws Nothing.
-
 [endsect]
 
 [//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:elapsed `get_laps_collector()`]
-
-__return_type `const S::laps_collector&`.
 
-__returns the laps_collector instance.
-
-[endsect]
-
-[/ /////////////////////////////
+[include stopwatches/reference.qbk]
 [//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:start_ec `start(ec)`]
-
-__effects Starts running the stopwatch.
-When there is an internal error stores the error code in the `ec` parameter if it is different from `throws()`.
-
-__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stop_ec `stop(ec)`]
-
-__effects Stops running the stopwatch.
-When there is an internal error stores the error code in the `ec` parameter if it is different from `throws()`.
-
-__throws Any exception the `__LapsCollector::store()` or `S::clock::now()` can throw when `ec` is `throws()`
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:restart_ec `restart(ec)`]
-
-__effects `stop`/`start` the stopwatch.
-
-__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`.
-
-[endsect]
-////////////////////////////// ]
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:laps_collector_req `LapsCollector` Requirements]
-
-A LapsCollector is collector of the duration of laps.
-
-A `C` meets the `LapsCollector` requirements if:
-
-* it meets the requirements specified in the following table.
-
-In this table `C` denote `LapsCollector` type, `c` is an instance of `C`.
-
-[table LapsCollector Requirements
- [[expression] [return type] [operational semantics]]
- [[`C::duration`] [`duration<>`] [The collected duration type.]]
- [[`c.store(c)`] [-] [stores a duration.]]
- [[`c.reset()`] [-] [clears the collector.]]
-]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:suspend `c.store(d)`]
-
-__effects Stores the duration `d` on the collector `c`.
-
-__throws `std::bad_alloc` when no memory is available`
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:resume `clear()`]
-
-__effects Clears the collector.
-
-__throws Nothing.
-
-[endsect]
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:suspendable_stopwatch_req `SuspendableStopwatch ` Requirements]
-
-A SuspendableStopwatch is a Stopwatch that in addition can be suspended and resumed.
-
-A `S` meets the `SuspendableStopwatch` requirements if:
-
-* `S` meets the __Stopwatch requirements, and
-* meets the requirements specified in the following table.
-
-In this table `S` denote `SuspendableStopwatch` type, `s` is an instance of `S`.
-
-[table Stopwatch Requirements
- [[expression] [return type] [operational semantics]]
- [[`S::scoped_suspend`] [`__stopwatch_suspender<S>`] [RAI which `suspend`/`resume` the `stopwatch`.]]
- [[`S::scoped_resume`] [`__stopwatch_resumer<S>`] [RAI which `resume`/`suspend` the `stopwatch`.]]
- [[`s.suspend()`] [-] [suspends a Stopwatch.]]
- [[`s.resume()`] [-] [resumes a Stopwatch.]]
- [[`sc.is_suspended()`] [`bool`] [whether the stopwatch is suspended or not.]]
-]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:suspend `s.suspend()`]
-
-__effects Suspends the stopwatch.
-
-__throws Any exception the `S::clock::now` function can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:resume `s.resume()`]
-
-__effects Resumes the stopwatch.
-
-__throws Any exception the `S::clock::now` function can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:is_suspended `sc.is_suspended()`]
-
-__return_type `bool`.
-
-__returns Whether the stopwatch is suspended or not.
-
-__throws Nothing.
-
-[endsect]
-
-[/ /////////////////////////////
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:suspend_ec `s.suspend(ec)`]
-
-__effects Suspends the stopwatch.
-
-__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:resume_ec `s.resume(ec)`]
-
-__effects Resumes the stopwatch.
-
-__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`
-
-[endsect]
-////////////////////////////// ]
-
-[endsect]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:stopwatch_scoped_hpp Header `<boost/chrono/stopwatches/stopwatch_scoped.hpp>`]
-[/==================================================]
-
- namespace boost {
- namespace chrono {
- template<class Stopwatch>
- class stopwatch_runner;
-
- template<class Stopwatch>
- class stopwatch_stopper;
-
- template<class Stopwatch>
- class stopwatch_suspender;
-
- template<class Stopwatch>
- class stopwatch_resumer;
- }
- }
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_runner Template Class `stopwatch_runner<>`]
-
-Maintains the stopwatch running during the lifetime.
-
- template<class Stopwatch>
- class stopwatch_runner
- {
- public:
- typedef Stopwatch stopwatch;
- stopwatch_runner() = delete;
- stopwatch_runner(const stopwatch_runner&) = delete;
- stopwatch_runner& operator=(const stopwatch_runner&) = delete;
-
- stopwatch_runner(stopwatch & s);
- ~stopwatch_runner();
- };
-
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c Constructor `stopwatch_runner(stopwatch &s)`]
-
-__requires `! s.is_running()`.
-
-__effects Stores a reference `s` and as if `s.start()`.
-
-__post_condition `s.is_running()`.
-
-__throws Any exception the `s.start()`can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:d Destructor `~stopwatch_runner()`]
-
-__effects As if `s.stop()`.
-
-__post_condition `! s.is_running()`.
-
-__throws Nothing.
-
-[endsect]
-
-[/ /////////////////////////////
- stopwatch_runner(stopwatch & s, system::error_code & ec);
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ec Constructor `stopwatch_runner(stopwatch &s, system::error_code &ec)`]
-
-__requires `! s.is_running()`.
-
-__effects Stores a reference `s` and as if `s.start(ec)`.
-
-__post_condition `s.is_running()`.
-
-__throws Any exception the `s.start(ec)`can throw when `ec` is `throws()`
-
-[endsect]
-////////////////////////////// ]
-
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_stopper Template Class `stopwatch_stopper<>`]
-
-Maintains the stopwatch stopped during the lifetime.
-
- template<class Stopwatch>
- class stopwatch_stopper
- {
- public:
- typedef Stopwatch stopwatch;
- stopwatch_stopper() = delete;
- stopwatch_stopper(const stopwatch_stopper&) = delete;
- stopwatch_stopper& operator=(const stopwatch_stopper&) = delete;
-
- stopwatch_stopper(stopwatch & s);
- ~stopwatch_stopper();
- };
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c Constructor `stopwatch_stopper(stopwatch &s)`]
-
-__requires `s.is_running()`.
-
-__effects Stores a reference `s` and as if `s.stop()`.
-
-__post_condition `! s.is_running()`.
-
-__throws Any exception the `s.stop()` can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:d Destructor `~stopwatch_stopper()`]
-
-__effects As if `s.start()`.
-
-__post_condition `s.is_running()`.
-
-__throws Nothing.
-
-[endsect]
-
-[/ /////////////////////////////
- stopwatch_stopper(stopwatch & s, system::error_code & ec);
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ec Constructor `stopwatch_stopper(stopwatch &s, system::error_code &ec)`]
-
-__requires `s.is_running()`.
-
-__effects Stores a reference `s` and as if `s.stop(ec)`.
-
-__post_condition `! s.is_running()`.
-
-__throws Any exception the `s.stop(ec)` can throw when `ec` is `throws()`
-
-[endsect]
-////////////////////////////// ]
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_suspender Template Class `stopwatch_suspender<>`]
-
-Maintains the stopwatch supended during the lifetime.
-
- template<class Stopwatch>
- class stopwatch_suspender
- {
- public:
- typedef Stopwatch stopwatch;
- stopwatch_suspender() = delete;
- stopwatch_suspender(const stopwatch_suspender&) = delete;
- stopwatch_suspender& operator=(const stopwatch_suspender&) = delete;
- stopwatch_suspender(stopwatch & s);
- ~stopwatch_suspender();
- };
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c Constructor `stopwatch_suspender(stopwatch &s)`]
-
-__requires `s.is_running() && ! s.is_suspended()`.
-
-__effects Stores a reference `s` and as if `s.suspend()`.
-
-__post_condition `s.is_running() && s.is_suspended()`.
-
-__throws Any exception the `s.suspend()` can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:d Destructor `~stopwatch_suspender()`]
-
-__effects As if `s.resume()`.
-
-__post_condition `s.is_running() && ! s.is_suspended()`.
-
-__throws Nothing.
-
-[endsect]
-
-[/ /////////////////////////////
- stopwatch_suspender(stopwatch & s, system::error_code & ec);
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ec Constructor `stopwatch_suspender(stopwatch &s, system::error_code &ec)`]
-
-__requires `s.is_running() && ! s.is_suspended()`.
-
-__effects Stores a reference `s` and as if `s.suspend(ec)`.
-
-__post_condition `s.is_running() && s.is_suspended()`.
-
-__throws Any exception the `s.suspend(ec)` can throw.
-
-[endsect]
-////////////////////////////// ]
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_resumer Template Class `stopwatch_resumer<>`]
-
-Maintains the stopwatch resumed during the lifetime.
-
- template<class Stopwatch>
- class stopwatch_resumer
- {
- public:
- typedef Stopwatch stopwatch;
- stopwatch_resumer() = delete;
- stopwatch_resumer(const stopwatch_resumer&) = delete;
- stopwatch_resumer& operator=(const stopwatch_resumer&) = delete;
- stopwatch_resumer(stopwatch & s);
- ~stopwatch_resumer();
- };
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c Constructor `stopwatch_resumer(stopwatch &s)`]
-
-__requires `s.is_running() && s.is_suspended()`.
-
-__effects Stores a reference `s` and as if `s.resume()`.
-
-__post_condition `s.is_running() && ! s.is_suspended()`.
-
-__throws Any exception the `s.resume()` can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:d Destructor `~stopwatch_resumer()`]
-
-__effects As if `s.suspend()`.
-
-__post_condition `s.is_running() && s.is_suspended()`.
-
-__throws Nothing.
-
-[endsect]
-
-[/ /////////////////////////////
- stopwatch_resumer(stopwatch & s, system::error_code & ec);
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ec Constructor `stopwatch_resumer(stopwatch &s, system::error_code &ec)`]
-
-__requires `s.is_running() && s.is_suspended()`.
-
-__effects Stores a reference `s` and as if `s.resume(ec)`.
-
-__post_condition `s.is_running() && ! s.is_suspended()`.
-
-__throws Any exception the `s.resume(ec)` can throw.
-
-[endsect]
-////////////////////////////// ]
-
-[endsect] [/ class ]
-
-[endsect] [/ header ]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:dont_start_hpp Header `<boost/chrono/stopwatches/dont_start.hpp>`]
-[/==================================================]
-
- namespace boost
- {
- namespace chrono
- {
- struct dont_start_t;
- static const dont_start_t dont_start;
- }
- }
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:dont_start_t Class `dont_start_t`]
-
-Type used to don't start a Stopwatch at construction time.
-
- struct dont_start_t { };
-
-[endsect] [/ class ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:dont_start Variable `dont_start`]
-
-Instance used to don't start a Stopwatch at construction time.
-
- static const dont_start_t dont_start = { };
-
-[endsect] [/ var ]
-[endsect] [/ header ]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:strict_stopwatch_hpp Header `<boost/chrono/stopwatches/strict_stopwatch.hpp>`]
-[/==================================================]
-
- namespace boost {
- namespace chrono {
- template <class __Clock=high_resolution_clock>
- class strict_stopwatch;
-
- // useful typedefs
- typedef <see above> system_strict_stopwatch;
- #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
- typedef <see above> steady_strict_stopwatch;
- #endif
- typedef <see above> high_resolution_strict_stopwatch;
- }}
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:strict_stopwatch Template Class `strict_stopwatch<>`]
-
-Knowing how long a part of a program takes to execute is useful in both test and production environments.
-A __strict_stopwatch` object measures elapsed time. It is recommended to use it with clocks that measure wall clock rather than CPU time since the intended use is performance measurement on systems where total elapsed time is more important than just process or CPU time.
-
-The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
-accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
-
-`strict_stopwatch <>` is a model of a __strict_stopwatch_concept.
-
- template <class __Clock> class strict_stopwatch {
- public:
- typedef Clock clock;
- typedef typename Clock::duration duration;
- typedef typename Clock::time_point time_point;
-
- strict_stopwatch( );
- ~strict_stopwatch();
-
- duration elapsed( );
-
- };
-
-Only the specificities of this class are documented here. See __strict_stopwatch_concept for the common parts.
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c1 Constructor `strict_stopwatch()`]
-
- strict_stopwatch();
-
-__effects constructs and starts the strict_stopwatch.
-
-__throws Any exception the `Clock::now()`can throw.
-
-[endsect]
-
-[/
- explicit strict_stopwatch( system::error_code & ec );
- duration elapsed( system::error_code & ec );
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c2 Constructor `strict_stopwatch( system::error_code &)`]
-
- explicit strict_stopwatch( system::error_code & ec = throws() );
-
-__effects constructs and starts the strict_stopwatch.
-
-__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
-
-[endsect]
-]
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:typedefs `strict_stopwatch` useful typedefs]
-
-The following typedef are provided as syntactic sugar.
-
- typedef strict_stopwatch< boost::chrono::system_clock > system_strict_stopwatch;
- #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
- typedef strict_stopwatch< boost::chrono:: steady_clock > steady_strict_stopwatch;
- #endif
- typedef strict_stopwatch< boost::chrono:: high_resolution_clock > high_resolution_strict_stopwatch;
-
-[endsect] [/ typedefs]
-[endsect] [/ header ]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:stopwatch_hpp Header `<boost/chrono/stopwatches/stopwatch.hpp>`]
-[/==================================================]
-
- namespace boost {
- namespace chrono {
- template<typename __Clock=high_resolution_clock, typename __LapsCollector=no_memory<typename Clock::duration> >
- class stopwatch;
-
- // useful typedefs
- typedef <see above> system_stopwatch;
- #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
- typedef <see above> steady_stopwatch;
- #endif
- typedef <see above> high_resolution_stopwatch;
- }}
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch Template Class `stopwatch<>`]
-
-A __stopwatch is a model of __Stopwatch taking as parameters the __Clock and the __LapsCollector.
-
-The main difference respect to a __strict_stopwatch is that the user can stop it.
-
-Each sequence of start-stop results in a new elapsed duration sample that is provided to the __LapsCollector.
-It is up to the __LapsCollector to do whatever it wants with each sample.
-
-Even if it is preferable to use process or thread wide clocks, the default of the Clock parameter is high_resolution_clock,
-as it is the single one ensured on all platforms.
-
-The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
-accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
-
-`stopwatch <>` is a model of a __Stopwatch.
-
- template<typename Clock, typename LapsCollector >
- class stopwatch
- {
- public:
- typedef Clock clock;
- typedef LapsCollector laps_collector;
- typedef typename Clock::duration duration;
- typedef typename Clock::time_point time_point;
- typedef typename Clock::rep rep;
- typedef typename Clock::period period;
- BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady;
-
- stopwatch();
- explicit stopwatch(const dont_start_t&) noexcept;
- explicit stopwatch(laps_collector const& coll);
- stopwatch(laps_collector const& acc, const dont_start_t&);
- ~stopwatch();
-
- void restart();
- void start();
- void stop();
- bool is_running() const;
-
- /**
- * Elapsed time getter for the current lap.
- *
- * Returns: the elapsed time since the last start if no internal error occur.
- *
- */
- duration elapsed_current_lap() const;
-
-
- duration elapsed() const;
- /**
- * Elapsed time for the last lap.
- *
- * Returns: the elapsed time of the last lap.
- *
- */
- duration last() const;
-
- void reset();
- laps_collector const& get_laps_collector() const noexcept;
-
- typedef stopwatch_runner<stopwatch<Clock, LapsCollector> > scoped_run;
- typedef stopwatch_stopper<stopwatch<Clock, LapsCollector> > scoped_stop;
-
- };
-
-
-Only the specificities of this class are documented here. See __Stopwatch for the common parts.
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c Constructor `stopwatch()`]
-
- stopwatch();
-
-__effects constructs and starts the stopwatch.
-
-__post_conditions: `is_running()`.
-
-__throws Any exception the `Clock::now()`can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ns Constructor `stopwatch( const dont_start_t& )`]
-
- explicit stopwatch(const dont_start_t&) noexcept;
-
-__effects constructs and not starts the stopwatch.
-
-__post_conditions: `! is_running()`.
-
-__throws Nothing`
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_coll Constructor `stopwatch(laps_collector const&)`]
-
- explicit stopwatch(laps_collector const& coll);
-
-__effects constructs copying the laps collector and starts the stopwatch.
-
-__post_conditions: `is_running()`.
-
-__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_coll_ns Constructor `stopwatch(laps_collector const&, const dont_start_t&)`]
-
- stopwatch(laps_collector const& acc, const dont_start_t&);
-
-__effects constructs copying the laps collector and don't starts the stopwatch.
-
-__post_conditions: `! is_running()`.
-
-__throws Any exception the __LapsCollector copy can throw`
-
-[endsect]
-
-
-
-
-
-[/
-
- explicit stopwatch(system::error_code & ec);
- stopwatch(laps_collector const& acc, system::error_code & ec);
- void restart(system::error_code & ec);
- void start(system::error_code & ec);
- void stop(system::error_code & ec);
- /**
- * Elapsed time getter for the current lap.
- *
- * Effects: Assign the error code if any internal error occur while retrieving the current time.
- *
- * Returns: the elapsed time since the start if no internal error occur.
- *
- */
- duration elapsed_current_lap(system::error_code & ec) const;
- duration elapsed(system::error_code & ec) const;
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ec Constructor `stopwatch( system::error_code &ec)`]
-
- explicit stopwatch( system::error_code & ec = throws() );
-
-__effects constructs and starts the stopwatch.
-
-__post_conditions: `ec || is_running()`.
-
-__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
-
-[endsect]
-]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_coll_ec Constructor `stopwatch(laps_collector const&, system::error_code &)`]
-
- explicit stopwatch(laps_collector const& acc, system::error_code & ec);
-
-__effects constructs copying the laps collector and starts the stopwatch. Assign the error code if any internal error occur while retrieving the current time.
-
-__post_conditions: `ec || is_running()`.
-
-__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw when `ec` is `throws()`
-
-[endsect]
-
-]
-
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:typedefs `stopwatch` useful typedefs]
-
-The following typedef are provided as syntactic sugar.
-
- typedef stopwatch< boost::chrono::system_clock > system_stopwatch;
- #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
- typedef stopwatch< boost::chrono:: steady_clock > steady_stopwatch;
- #endif
- typedef stopwatch< boost::chrono:: high_resolution_clock > high_resolution_stopwatch;
-
-[endsect] [/ typedefs]
-[endsect] [/ header ]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:suspendable_stopwatch_hpp Header `<boost/chrono/stopwatches/suspendable_stopwatch.hpp>`]
-[/==================================================]
-
- namespace boost {
- namespace chrono {
- template<typename __Clock=high_resolution_clock, typename __LapsCollector=no_memory<typename Clock::duration> >
- class suspendable_stopwatch;
-
- // useful typedefs
- typedef <see above> system_suspendable_stopwatch;
- #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
- typedef <see above> steady_suspendable_stopwatch;
- #endif
- typedef <see above> high_resolution_suspendable_stopwatch;
- }}
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:suspendable_stopwatch Template Class `suspendable_stopwatch<>`]
-
-A __suspendable_stopwatch is a model of __SuspendableStopwatch taking as parameters the __Clock and the __LapsCollector.
-
-The main difference respect to a __stopwatch is that the user can suspend/resume it.
-
-Each sequence of start-stop results in a new elapsed duration sample that is provided to the __LapsCollector.
-This lap can be suspended/resumed.
-
-Even if it is preferable to use process or thread wide clocks, the default of the Clock parameter is high_resolution_clock,
-as it is the single one ensured on all platforms.
-
-The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
-accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
-
-`suspendable_stopwatch<>` is a model of a __SuspendableStopwatch.
-
- template<typename Clock, typename LapsCollector >
- class suspendable_stopwatch
- {
- public:
- typedef Clock clock;
- typedef LapsCollector laps_collector;
- typedef typename Clock::duration duration;
- typedef typename Clock::time_point time_point;
- typedef typename Clock::rep rep;
- typedef typename Clock::period period;
- BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady;
-
- suspendable_stopwatch();
- explicit suspendable_stopwatch(const dont_start_t&) noexcept;
- explicit suspendable_stopwatch(laps_collector const& coll);
- suspendable_stopwatch(laps_collector const& acc, const dont_start_t&);
-
- ~suspendable_stopwatch();
-
- void restart();
- void start();
- void stop();
- void suspend();
- void resume();
- void reset();
-
- bool is_running() const;
- bool is_elapsed() const;
- duration elapsed_current_lap() const;
- duration elapsed() const;
- duration last() const;
- laps_collector const& get_laps_collector() const noexcept;
-
- typedef stopwatch_runner<suspendable_stopwatch<Clock, LapsCollector> > scoped_run;
- typedef stopwatch_stopper<suspendable_stopwatch<Clock, LapsCollector> > scoped_stop;
- typedef stopwatch_suspender<suspendable_stopwatch<Clock, LapsCollector> > scoped_suspend;
- typedef stopwatch_resumer<suspendable_stopwatch<Clock, LapsCollector> > scoped_resume;
-
- };
-
-
-Only the specificities of this class are documented here. See __Stopwatch for the common parts.
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c Constructor `suspendable_stopwatch()`]
-
- suspendable_stopwatch();
-
-__effects constructs and starts the stopwatch.
-
-__post_conditions: `is_running() && ! is_suspended()`.
-
-__throws Any exception the `Clock::now()`can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ns Constructor `suspendable_stopwatch( const dont_start_t& )`]
-
- explicit suspendable_stopwatch(const dont_start_t&) noexcept;
-
-__effects constructs and not starts the stopwatch.
-
-__post_conditions: `! is_running() && ! is_suspended()`.
-
-__throws Nothing`
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_coll Constructor `suspendable_stopwatch(laps_collector const&)`]
-
- explicit suspendable_stopwatch(laps_collector const& coll);
-
-__effects constructs copying the laps collector and starts the stopwatch.
-
-__post_conditions: `is_running() && ! is_suspended()`.
-
-__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw.
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_coll_ns Constructor `suspendable_stopwatch(laps_collector const&, const dont_start_t&)`]
-
- suspendable_stopwatch(laps_collector const& acc, const dont_start_t&);
-
-__effects constructs copying the laps collector and don't starts the stopwatch.
-
-__post_conditions: `! is_running() && ! is_suspended()`.
-
-__throws Any exception the __LapsCollector copy can throw`
-
-[endsect]
-
-
-[/
-
- explicit suspendable_stopwatch(system::error_code & ec);
- suspendable_stopwatch(laps_collector const& acc, system::error_code & ec);
- void restart(system::error_code & ec);
- void start(system::error_code & ec);
- void stop(system::error_code & ec);
- void suspend(system::error_code & ec);
- void resume(system::error_code & ec);
- void reset(system::error_code & ec);
- duration elapsed_current_lap(system::error_code & ec) const;
- duration elapsed(system::error_code & ec) const;
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_ec Constructor `suspendable_stopwatch( system::error_code &ec)`]
-
- explicit suspendable_stopwatch( system::error_code & ec = throws() );
-
-__effects constructs and starts the stopwatch.
-
-__post_conditions: `is_running() && ! is_suspended()`.
-
-__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:c_coll_ec Constructor `suspendable_stopwatch(laps_collector const&, system::error_code &)`]
-
- explicit suspendable_stopwatch(laps_collector const& acc, system::error_code & ec);
-
-__effects constructs copying the laps collector and starts the stopwatch. Assign the error code if any internal error occur while retrieving the current time.
-
-__post_conditions: `ec || (is_running() && ! is_suspended())`.
-
-__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw when `ec` is `throws()`
-
-[endsect]
-]
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:typedefs `suspendable_stopwatch` useful typedefs]
-
-The following typedef are provided as syntactic sugar.
-
- typedef suspendable_stopwatch< boost::chrono::system_clock > system_suspendable_stopwatch;
- #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
- typedef suspendable_stopwatch< boost::chrono:: steady_clock > steady_suspendable_stopwatch;
- #endif
- typedef suspendable_stopwatch< boost::chrono:: high_resolution_clock > high_resolution_suspendable_stopwatch;
-
-[endsect] [/ typedefs]
-[endsect] [/ header ]
-
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:collectors Collectors]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:no_memory_hpp Header `<boost/chrono/stopwatches/collectors/no_memory.hpp>`]
-[/==================================================]
-
- namespace boost
- {
- namespace chrono
- {
-
- template<typename Duration>
- struct no_memory;
-
- }
- }
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:no_memory Class `no_memory`]
-
- template<typename Duration>
- struct no_memory
- {
- typedef Duration duration;
-
- duration elapsed() const;
- duration last() const;
- void store(duration const& );
- void reset();
-
- };
-
-[endsect]
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:last_lap_hpp Header `<boost/chrono/stopwatches/collectors/last_lap.hpp>`]
-[/==================================================]
-
- namespace boost
- {
- namespace chrono
- {
-
- template<typename Duration>
- struct last_lap;
-
- }
- }
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:last_lap Class `last_lap`]
-
- template<typename Duration>
- struct last_lap
- {
- typedef Duration duration;
- duration elapsed() const;
- duration last() const;
- void store(duration const& d);
- void reset();
-
- };
-
-[endsect]
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:laps_accumulator_set_hpp Header `<boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp>`]
-[/==================================================]
-
- namespace boost
- {
- namespace chrono
- {
-
- template<
- typename Duration,
- typename Features = accumulators::features<accumulators::tag::count,
- accumulators::tag::sum, accumulators::tag::min,
- accumulators::tag::max, accumulators::tag::mean>,
- typename Weight = void>
- struct laps_accumulator_set;
-
- }
- }
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:laps_accumulator_set Class `laps_accumulator_set`]
-
- template<
- typename Duration,
- typename Features = accumulators::features<accumulators::tag::count,
- accumulators::tag::sum, accumulators::tag::min,
- accumulators::tag::max, accumulators::tag::mean>,
- typename Weight = void>
- struct laps_accumulator_set : last_lap<Duration>
- {
- typedef Duration duration;
- typedef accumulators::accumulator_set<typename duration::rep, Features,
- Weight> storage_type;
-
- duration elapsed() const;
- void store(duration const& d);
- void reset();
- storage_type const& accumulator_set() const;
-
-
- };
-
-[endsect]
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:laps_sequence_container_hpp Header `<boost/chrono/stopwatches/collectors/laps_sequence_container.hpp>`]
-[/==================================================]
-
- namespace boost
- {
- namespace chrono
- {
-
- template<
- typename Duration,
- typename SequenceContainer = std::list<Duration>
- >
- struct laps_sequence_container;
-
- }
- }
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:laps_sequence_container Class `laps_sequence_container`]
-
- template<
- typename Duration,
- typename SequenceContainer = std::list<Duration>
- >
- struct laps_sequence_container
- {
- typedef Duration duration;
- typedef SequenceContainer storage_type;
- typedef typename SequenceContainer::iterator iterator;
- typedef typename SequenceContainer::const_iterator const_iterator;
-
- duration elapsed() const;
- duration last() const;
- storage_type const& container() const;
- void store(duration const& d);
- void reset();
- };
-
-[endsect]
-[endsect] [/ header ]
-[endsect] [/ collectors ]
-[endsect] [/ stopwatches]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopclocks Stopclocks]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:formatter_req `Formatter` Requirements]
-
-A Formatter outputs on a given ostream a formatted string combining informations from a __StrictStopwatch, the format and the double precision.
-
-A Formatter must meet the requirements in the following Table.
-
-In this table `F` denote a Formatter type, `f` is an instance of `F`, `p` is an `int`, `ds` is a `__duration_style`, and `os` is a `F::ostream_type`.
-
-[table Formatter Requirements
- [[expression] [return type] [operational semantics]]
- [[`F::char_type`] [The associated char type.] [-]]
- [[`F::string_type`] [The associated string type.] [-]]
- [[`F::format_type`] [The associated format type ] [-]]
- [[`F::ostream_type`] [The associated output stream type ] [-]]
- [[`F::`] [A model of ] [-]]
- [[`F()`] [F&&] [Default constructible.]]
- [[`F(os)`] [F&&] [Explicit Constructible from an std::basic_ostream.]]
- [[`F(os)`] [F&&] [Explicit Constructible from an std::basic_ostream.]]
- [[`f.set_precision(p)`] [`-`] [Sets the precision used when displaying a double.]]
- [[`f.set_duration_style(ds)`] [`-`] [Sets the duration style used when displaying a duration.]]
- [[`f(s)`] [`S::time_point`] [outputs on `os` a formatted string combining informations from the Stopwatch `s`, the format `f` and the double precision `p`.]]
-]
-
-
-Models of `Formatter`:
-
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopclock_req `StopClock` Requirements]
-
-A Stopclock is a Stopwatch that is able to make reports associated to the collected samples.
-Stopclocks ensure that a report is done once and only once.
-
-A Stopclock must meet the requirements in the following Table.
-In this table `S` denote a Stopclock type and `s` is an instance of `S`, `fmt` `f` is `const S::char_type *` or `const S::string_type &` or `S::format_type`.
-
-[table Stopclock Requirements
- [[expression] [return type] [operational semantics]]
- [[`S::stopwatch_type`] [A model of __Stopwatch] [-]]
- [[`S::formater_type`] [A model of __Formater] [-]]
-
- [[`S(fmt)`] [S&&] [Constructor with specific format.]]
- [[`s::report()`] [`-`] [Makes a report of the stopclock samples.]]
- [[`s::reported()`] [`bool`] [States if a report has already been done.]]
-]
-
-
-Models of `Stopclock`:
-
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:stopwatch_reporter_hpp Header `<boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp>`]
-[/==================================================]
-
- namespace boost
- {
- namespace chrono
- {
-
- template<
- class CharT,
- class Stopwatch,
- class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
- class basic_stopwatch_reporter;
-
- template<
- class Stopwatch,
- class Formatter = typename basic_stopwatch_reporter_default_formatter<char, Stopwatch>::type>
- class stopwatch_reporter;
-
- template<class Stopwatch, class Formatter>
- struct basic_stopwatch_reporter_default_formatter<char, stopwatch_reporter<Stopwatch, Formatter> >;
-
- template<
- class Stopwatch,
- class Formatter = typename basic_stopwatch_reporter_default_formatter<wchar_t, Stopwatch>::type>
- class wstopwatch_reporter;
-
- template<class Stopwatch, class Formatter>
- struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >;
-
- }
- }
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:basic_stopwatch_reporter Template Class `basic_stopwatch_reporter`]
-
- template<
- class CharT,
- class Stopwatch,
- class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
- class basic_stopwatch_reporter: public Stopwatch
- {
- public:
- typedef typename Stopwatch::clock clock;
- typedef Stopwatch stopwatch_type;
- typedef Formatter formatter_type;
-
- basic_stopwatch_reporter(const basic_stopwatch_reporter&) = delete;
- basic_stopwatch_reporter& operator=(const basic_stopwatch_reporter&) = delete;
-
- basic_stopwatch_reporter() noexcept;
- explicit basic_stopwatch_reporter(system::error_code & ec);
- explicit basic_stopwatch_reporter(const dont_start_t& tag) noexcept;
- explicit basic_stopwatch_reporter(const typename Formatter::char_type* fmt);
- explicit basic_stopwatch_reporter(typename Formatter::string_type const& fmt);
- explicit basic_stopwatch_reporter(formatter_type fmt);
-
- ~basic_stopwatch_reporter() noexcept;
-
- bool reported() const;
- formatter_type& format();
-
- void report() noexcept;
-
- protected:
- formatter_type formatter_;
- bool reported_;
-
- };
-
-[endsect]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_reporter Template Class `stopwatch_reporter`]
-
- template<class Stopwatch, class Formatter>
- class stopwatch_reporter: public basic_stopwatch_reporter<char, Stopwatch, Formatter>
- {
- public:
- typedef typename Stopwatch::clock clock;
- typedef Stopwatch stopwatch_type;
- typedef Formatter formatter_type;
-
- stopwatch_reporter(const stopwatch_reporter&) = delete;
- stopwatch_reporter& operator=(const stopwatch_reporter&) = delete;
- stopwatch_reporter();
- explicit stopwatch_reporter(system::error_code & ec);
- explicit stopwatch_reporter(const dont_start_t& tag) noexcept;
- explicit stopwatch_reporter(formatter_type const& fmt);
- explicit stopwatch_reporter(const typename Formatter::char_type* fmt);
- explicit stopwatch_reporter(typename Formatter::string_type const& fmt);
-
- typedef stopwatch_runner<stopwatch_reporter<Stopwatch, Formatter> > scoped_run;
- typedef stopwatch_stopper<stopwatch_reporter<Stopwatch, Formatter> > scoped_stop;
- typedef stopwatch_suspender<stopwatch_reporter<Stopwatch, Formatter> > scoped_suspend;
- typedef stopwatch_resumer<stopwatch_reporter<Stopwatch, Formatter> > scoped_resume;
-
- };
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:stopwatch_reporter_ps Partial Specialization `basic_stopwatch_reporter_default_formatter<char_t, stopwatch_reporter<Stopwatch, Formatter> >`]
-
- template<class Stopwatch, class Formatter>
- struct basic_stopwatch_reporter_default_formatter<char_t, stopwatch_reporter<Stopwatch, Formatter> >
- {
- typedef Formatter type;
- };
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:wstopwatch_reporter Template Class `wstopwatch_reporter`]
-
- template<class Stopwatch, class Formatter>
- class wstopwatch_reporter: public basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter>
- {
- public:
- typedef typename Stopwatch::clock clock;
- typedef Stopwatch stopwatch_type;
- typedef Formatter formatter_type;
-
- wstopwatch_reporter(const wstopwatch_reporter&) = delete;
- wstopwatch_reporter& operator=(const wstopwatch_reporter&) = delete;
- wstopwatch_reporter();
- explicit wstopwatch_reporter(system::error_code & ec);
- explicit wstopwatch_reporter(const dont_start_t& tag) noexcept;
-
- explicit wstopwatch_reporter(formatter_type const& fmt);
- explicit wstopwatch_reporter(const typename Formatter::char_type* fmt);
- explicit wstopwatch_reporter(typename Formatter::string_type const& fmt);
- typedef stopwatch_runner<wstopwatch_reporter<Stopwatch, Formatter> > scoped_run;
- typedef stopwatch_stopper<wstopwatch_reporter<Stopwatch, Formatter> > scoped_stop;
- typedef stopwatch_suspender<wstopwatch_reporter<Stopwatch, Formatter> > scoped_suspend;
- typedef stopwatch_resumer<wstopwatch_reporter<Stopwatch, Formatter> > scoped_resume;
-
- };
-
-
-[endsect]
-
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:wstopwatch_reporter_ps Partial Specialization `basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >`]
-
- template<class Stopwatch, class Formatter>
- struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >
- {
- typedef Formatter type;
- };
-
-[endsect]
-
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:strict_stopclock_hpp Header `<boost/chrono/stopwatches/reporters/strict_stopclock.hpp>`]
-[/==================================================]
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:stopclock_hpp Header `<boost/chrono/stopwatches/reporters/stopclock.hpp>`]
-[/==================================================]
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[section:formatters Formatters]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:base_formatter_hpp Header `<boost/chrono/stopwatches/formatters/base_formatter.hpp>`]
-[/==================================================]
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:elapsed_formatter_hpp Header `<boost/chrono/stopwatches/formatters/elapsed_formatter.hpp>`]
-[/==================================================]
-
-[endsect] [/ header ]
-[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
-[/==================================================]
-[section:accumulator_set_formatter_hpp Header `<boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp>`]
-[/==================================================]
-
-[endsect] [/ header ]
-[endsect] [/ formatters ]
-[endsect] [/ reporters ]
 
 
 [//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]

Added: trunk/libs/chrono/doc/stopwatches/description.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/doc/stopwatches/description.qbk 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
@@ -0,0 +1,37 @@
+[/
+ / Copyright (c) 2009-20012 Vicente J. Botet Escriba
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+
+[/===================]
+[/section Description]
+[/===================]
+
+
+[/ /////////////////////////////////////////////////////
+[heading Stopwatch/Stopclocks framework]
+
+On top of the core facilities, __Boost_Chrono provides:
+
+Stopwatches: Some facility to measure elapsed time with the ability to start, stop, suspend, or resume measurement.
+
+* __StrictStopwatch, __Stopwatch, __SuspendableStopwatch concepts.
+* __strict_stopwatch, model of __StrictStopwatch capturing elapsed __Clock times.
+* __laps_stopwatch, model of __Stopwatch allowing in addition to start and stop the capture of elapsed __Clock times.
+* __suspendable_stopwatch, model of __SuspendableStopwatch allowing in addition to suspend and resume the capture of elapsed __Clock times.
+* __laps_stopwatch and __suspendable_stopwatch have __LapsCollector template parameter that allows to store information of the samples defined by a cycle start-stop.
+
+Stopclocks: a complete time reporting package that can be invoked in a single line of code.
+
+* __stopwatch_reporter`<__Stopwatch,__Formatter>`, convenient reporting to an output stream (including wide char streams) of the elapsed time of models of __Stopwatch results.
+* Some basic __Formatters.
+* `__strict_stopclock<__Clock>` shortcut of `__stopwatch_reporter<__strict_stopwatch<__Clock>>`
+* `__stopclock<__Clock>` shortcut of `__stopwatch_reporter<__stopwatch<__Clock>>`
+* `__suspendable_stopclock<__Clock>` shortcut of `__stopwatch_reporter<__suspendable_stopwatch<__Clock>>`
+
+] [/////////////////////////////////////////////////////]
+
+

Added: trunk/libs/chrono/doc/stopwatches/hello.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/doc/stopwatches/hello.qbk 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
@@ -0,0 +1,34 @@
+[/
+ / Copyright (c) 2009-20012 Vicente J. Botet Escriba
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+
+[/=====================]
+[/section Hello World! ]
+[/=====================]
+
+If all you want to do is to time a program's execution, here is a complete program (stopclock_example.cpp):
+
+ #include <boost/chrono_io.hpp>
+ #include <boost/chrono/stopwatches/reporters/stopclock.hpp>
+ #include <cmath>
+
+ int main()
+ {
+ boost::chrono::system_strict_stopclock _;
+
+ for ( long i = 0; i < 10000000; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+ }
+
+Output was:
+
+ 0.832 seconds
+
+
+

Added: trunk/libs/chrono/doc/stopwatches/motivation.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/doc/stopwatches/motivation.qbk 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
@@ -0,0 +1,43 @@
+[/
+ / Copyright (c) 2009-20012 Vicente J. Botet Escriba
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+
+[/==================]
+[/section Motivation]
+[/==================]
+
+
+[heading Measuring elapsed time]
+
+Knowing how long a program, a function or a specific code block takes to execute is useful in both test and production environments.
+__Boost_Chrono introduces the __strict_stopwatch_concept concept which is a mechanism to measure the elapsed time.
+__strict_stopwatch`<>` is the basic model of __strict_stopwatch_concept.
+
+[heading Reporting elapsed time]
+
+It is often necessary to report elapsed time on a user display or in a log file. __stopwatch_reporter provides a runtime reporting mechanism for this purpose which can be invoked in just one line of code.
+
+ using namespace boost::chrono;
+ int main()
+ {
+ __stopwatch_reporter<__stopwatch<__process_cpu_clocks> > _;
+ // ...
+ }
+
+Will produce the following output
+
+ real 0.034s, cpu 0.031s (93.0%), user 0.031s, system 0.000s
+
+As this is one of the expression more commonly use, the library provides a __stopclock shortcut so the preceding can be written as
+
+ int main()
+ {
+ __stopclock<__process_cpu_clocks> _;
+ // ...
+ }
+
+

Added: trunk/libs/chrono/doc/stopwatches/reference.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/doc/stopwatches/reference.qbk 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
@@ -0,0 +1,1572 @@
+[/
+ / Copyright (c) 2009-20010 Vicente J. Botet Escriba
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+[/=================]
+[/section:reference Reference ]
+[/=================]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatches Stopwatches]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:strict_stopwatch_req `StrictStopwatch` Requirements]
+
+A StrictStopwatch measure the amount of time elapsed from a start point in time.
+
+While __Clock are static and not instantiated, `StrictStopwatch` are instantiated and associated to a given __Clock.
+
+A `S` meets the `StrictStopwatch` requirements if:
+
+* `S::clock` meets the __Clock requirements, and
+* meets the requirements specified in the following table.
+
+In this table `S` denote a StrictStopwatch type. `sc` is an instance of `S` const.
+
+[table StrictStopwatch Requirements
+ [[expression] [return type] [operational semantics]]
+ [[`S::clock`] [A model of __Clock.] [The clock associated to this Stopwatch.]]
+ [[`S::duration`] [`S::clock::duration`] [The __duration type of the `clock`.]]
+ [[`S::time_point`] [`S::clock::time_point`] [The __time_point type of the `clock`.]]
+ [[`S()`] [`S&&`] [Constructd a stopwatch.]]
+ [[`sc.elapsed()`] [`S::duration`] [the elapsed time while the __StrictStopwatch was running.]]
+
+]
+
+
+[/ /////////////////////////////
+
+, `ec` is instance of `system::error_code`
+
+ [[`S(ec)`] [`S&&`] [Constructd a stopwatch.]]
+ [[`sc.elapsed(ec)`] [`S::duration`] [the elapsed time while the __StrictStopwatch was running.]]
+
+////////////////////////////// ]
+
+Models of `StrictStopwatch `:
+
+* __strict_stopwatch
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:elapsed `sc.elapsed()`]
+
+__return_type `S::duration`.
+
+__returns the elapsed time.
+
+[endsect]
+
+[/ /////////////////////////////
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:elapsed_ec `sc.elapsed(ec)`]
+
+__return_type `S::duration`.
+
+__returns the elapsed time or `S::duration::zero()` if an error occurred.
+
+__effects When there is an internal error stores the error code in the `ec` parameter`.
+
+[endsect]
+////////////////////////////// ]
+[endsect]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_req `Stopwatch` Requirements]
+
+As a __StrictStopwatch, a __Stopwatch measure the amount of time elapsed from a start point in time.
+The main difference is that a __Stopwatch can be started and stopped (and restarted).
+The duration between these two time points is called a lap. It could have in addition the capability to collect these lap samples.
+
+A `S` meets the `Stopwatch` requirements if:
+
+* `S` meets the __StrictStopwatch requirements, and
+* meets the requirements specified in the following table.
+
+In this table `S` denote `Stopwatch` type. `s` is an instance of `S`, `sc` is an instance of `S` const.
+
+[table Stopwatch Requirements
+ [[expression] [return type] [operational semantics]]
+ [[`S::laps_collector `] [ A model of __LapsCollector] [Collects the laps's samples.]]
+ [[`S::scoped_run`] [`__stopwatch_runner<S>`] [RAI which `start`/`stop` the `stopwatch`.]]
+ [[`S::scoped_stop`] [`__stopwatch_stopper<S>`] [RAI which `stop`/`start` the `stopwatch`.]]
+
+ [[`S(dont_start)`] [`S&&`] [Constructd a stopwatch.]]
+ [[`S(coll)`] [`S&&`] [Constructd a stopwatch.]]
+
+ [[`s.start()`] [-] [starts a Stopwatch.]]
+ [[`s.stop()`] [-] [stops a Stopwatch.]]
+ [[`s.stop(ec)`] [-] [stops a Stopwatch.]]
+ [[`s.restart()`] [-] [restarts a Stopwatch.]]
+ [[`s.reset()`] [-] [Resets as if it was constructed again.]]
+
+ [[`sc.is_running()`] [`bool`] [whether the stopwatch is running or not.]]
+ [[`sc.elapsed_current_lap()`] [`S::duration`] [the elapsed time since the last start.]]
+ [[`sc.is_running()`] [bool] [true if the Stopwatch is running.]]
+ [[`sc.lap_collector()`] [`S::laps_collector const&`] [the elapsed time while the Stopwatch was running.]]
+
+]
+
+
+[/ /////////////////////////////
+
+`ec` is instance of `system::error_code`
+
+ [[`S(coll,ec)`] [`S&&`] [Constructd a stopwatch.]]
+ [[`s.start(ec)`] [-] [starts a Stopwatch.]]
+ [[`s.restart(ec)`] [-] [restarts a Stopwatch.]]
+ [[`s.reset(ec)`] [-] [Resets as if it was constructed again.]]
+ [[`sc.elapsed_current_lap(ec)`] [`S::duration`] [the elapsed time since the last start.]]
+
+////////////////////////////// ]
+
+Models of `Stopwatch`:
+
+* __stopwatch
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:start `start()`]
+
+__effects Starts running the stopwatch.
+
+__throws Any exception the `S::clock::now()` function can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stop `stop()`]
+
+__effects Stops running the stopwatch.
+
+__throws Any exception the __LapsCollector can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:restart `restart()`]
+
+__effects `stop`/`start` the stopwatch.
+
+__throws Any exception the `S::clock::now` function can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:is_running `sc.is_running()`]
+
+__return_type `bool`.
+
+__returns Whether the stopwatch is running or not.
+
+__throws Nothing.
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:elapsed `get_laps_collector()`]
+
+__return_type `const S::laps_collector&`.
+
+__returns the laps_collector instance.
+
+[endsect]
+
+[/ /////////////////////////////
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:start_ec `start(ec)`]
+
+__effects Starts running the stopwatch.
+When there is an internal error stores the error code in the `ec` parameter if it is different from `throws()`.
+
+__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stop_ec `stop(ec)`]
+
+__effects Stops running the stopwatch.
+When there is an internal error stores the error code in the `ec` parameter if it is different from `throws()`.
+
+__throws Any exception the `__LapsCollector::store()` or `S::clock::now()` can throw when `ec` is `throws()`
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:restart_ec `restart(ec)`]
+
+__effects `stop`/`start` the stopwatch.
+
+__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`.
+
+[endsect]
+////////////////////////////// ]
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:laps_collector_req `LapsCollector` Requirements]
+
+A LapsCollector is collector of the duration of laps.
+
+A `C` meets the `LapsCollector` requirements if:
+
+* it meets the requirements specified in the following table.
+
+In this table `C` denote `LapsCollector` type, `c` is an instance of `C`.
+
+[table LapsCollector Requirements
+ [[expression] [return type] [operational semantics]]
+ [[`C::duration`] [`duration<>`] [The collected duration type.]]
+ [[`c.store(c)`] [-] [stores a duration.]]
+ [[`c.reset()`] [-] [clears the collector.]]
+]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:suspend `c.store(d)`]
+
+__effects Stores the duration `d` on the collector `c`.
+
+__throws `std::bad_alloc` when no memory is available`
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:resume `clear()`]
+
+__effects Clears the collector.
+
+__throws Nothing.
+
+[endsect]
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:suspendable_stopwatch_req `SuspendableStopwatch ` Requirements]
+
+A SuspendableStopwatch is a Stopwatch that in addition can be suspended and resumed.
+
+A `S` meets the `SuspendableStopwatch` requirements if:
+
+* `S` meets the __Stopwatch requirements, and
+* meets the requirements specified in the following table.
+
+In this table `S` denote `SuspendableStopwatch` type, `s` is an instance of `S`.
+
+[table Stopwatch Requirements
+ [[expression] [return type] [operational semantics]]
+ [[`S::scoped_suspend`] [`__stopwatch_suspender<S>`] [RAI which `suspend`/`resume` the `stopwatch`.]]
+ [[`S::scoped_resume`] [`__stopwatch_resumer<S>`] [RAI which `resume`/`suspend` the `stopwatch`.]]
+ [[`s.suspend()`] [-] [suspends a Stopwatch.]]
+ [[`s.resume()`] [-] [resumes a Stopwatch.]]
+ [[`sc.is_suspended()`] [`bool`] [whether the stopwatch is suspended or not.]]
+]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:suspend `s.suspend()`]
+
+__effects Suspends the stopwatch.
+
+__throws Any exception the `S::clock::now` function can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:resume `s.resume()`]
+
+__effects Resumes the stopwatch.
+
+__throws Any exception the `S::clock::now` function can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:is_suspended `sc.is_suspended()`]
+
+__return_type `bool`.
+
+__returns Whether the stopwatch is suspended or not.
+
+__throws Nothing.
+
+[endsect]
+
+[/ /////////////////////////////
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:suspend_ec `s.suspend(ec)`]
+
+__effects Suspends the stopwatch.
+
+__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:resume_ec `s.resume(ec)`]
+
+__effects Resumes the stopwatch.
+
+__throws Any exception the `S::clock::now` function can throw when `ec` is `throws()`
+
+[endsect]
+////////////////////////////// ]
+
+[endsect]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:stopwatch_scoped_hpp Header `<boost/chrono/stopwatches/stopwatch_scoped.hpp>`]
+[/==================================================]
+
+ namespace boost {
+ namespace chrono {
+ template<class Stopwatch>
+ class stopwatch_runner;
+
+ template<class Stopwatch>
+ class stopwatch_stopper;
+
+ template<class Stopwatch>
+ class stopwatch_suspender;
+
+ template<class Stopwatch>
+ class stopwatch_resumer;
+ }
+ }
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_runner Template Class `stopwatch_runner<>`]
+
+Maintains the stopwatch running during the lifetime.
+
+ template<class Stopwatch>
+ class stopwatch_runner
+ {
+ public:
+ typedef Stopwatch stopwatch;
+ stopwatch_runner() = delete;
+ stopwatch_runner(const stopwatch_runner&) = delete;
+ stopwatch_runner& operator=(const stopwatch_runner&) = delete;
+
+ stopwatch_runner(stopwatch & s);
+ ~stopwatch_runner();
+ };
+
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c Constructor `stopwatch_runner(stopwatch &s)`]
+
+__requires `! s.is_running()`.
+
+__effects Stores a reference `s` and as if `s.start()`.
+
+__post_condition `s.is_running()`.
+
+__throws Any exception the `s.start()`can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:d Destructor `~stopwatch_runner()`]
+
+__effects As if `s.stop()`.
+
+__post_condition `! s.is_running()`.
+
+__throws Nothing.
+
+[endsect]
+
+[/ /////////////////////////////
+ stopwatch_runner(stopwatch & s, system::error_code & ec);
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ec Constructor `stopwatch_runner(stopwatch &s, system::error_code &ec)`]
+
+__requires `! s.is_running()`.
+
+__effects Stores a reference `s` and as if `s.start(ec)`.
+
+__post_condition `s.is_running()`.
+
+__throws Any exception the `s.start(ec)`can throw when `ec` is `throws()`
+
+[endsect]
+////////////////////////////// ]
+
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_stopper Template Class `stopwatch_stopper<>`]
+
+Maintains the stopwatch stopped during the lifetime.
+
+ template<class Stopwatch>
+ class stopwatch_stopper
+ {
+ public:
+ typedef Stopwatch stopwatch;
+ stopwatch_stopper() = delete;
+ stopwatch_stopper(const stopwatch_stopper&) = delete;
+ stopwatch_stopper& operator=(const stopwatch_stopper&) = delete;
+
+ stopwatch_stopper(stopwatch & s);
+ ~stopwatch_stopper();
+ };
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c Constructor `stopwatch_stopper(stopwatch &s)`]
+
+__requires `s.is_running()`.
+
+__effects Stores a reference `s` and as if `s.stop()`.
+
+__post_condition `! s.is_running()`.
+
+__throws Any exception the `s.stop()` can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:d Destructor `~stopwatch_stopper()`]
+
+__effects As if `s.start()`.
+
+__post_condition `s.is_running()`.
+
+__throws Nothing.
+
+[endsect]
+
+[/ /////////////////////////////
+ stopwatch_stopper(stopwatch & s, system::error_code & ec);
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ec Constructor `stopwatch_stopper(stopwatch &s, system::error_code &ec)`]
+
+__requires `s.is_running()`.
+
+__effects Stores a reference `s` and as if `s.stop(ec)`.
+
+__post_condition `! s.is_running()`.
+
+__throws Any exception the `s.stop(ec)` can throw when `ec` is `throws()`
+
+[endsect]
+////////////////////////////// ]
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_suspender Template Class `stopwatch_suspender<>`]
+
+Maintains the stopwatch supended during the lifetime.
+
+ template<class Stopwatch>
+ class stopwatch_suspender
+ {
+ public:
+ typedef Stopwatch stopwatch;
+ stopwatch_suspender() = delete;
+ stopwatch_suspender(const stopwatch_suspender&) = delete;
+ stopwatch_suspender& operator=(const stopwatch_suspender&) = delete;
+ stopwatch_suspender(stopwatch & s);
+ ~stopwatch_suspender();
+ };
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c Constructor `stopwatch_suspender(stopwatch &s)`]
+
+__requires `s.is_running() && ! s.is_suspended()`.
+
+__effects Stores a reference `s` and as if `s.suspend()`.
+
+__post_condition `s.is_running() && s.is_suspended()`.
+
+__throws Any exception the `s.suspend()` can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:d Destructor `~stopwatch_suspender()`]
+
+__effects As if `s.resume()`.
+
+__post_condition `s.is_running() && ! s.is_suspended()`.
+
+__throws Nothing.
+
+[endsect]
+
+[/ /////////////////////////////
+ stopwatch_suspender(stopwatch & s, system::error_code & ec);
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ec Constructor `stopwatch_suspender(stopwatch &s, system::error_code &ec)`]
+
+__requires `s.is_running() && ! s.is_suspended()`.
+
+__effects Stores a reference `s` and as if `s.suspend(ec)`.
+
+__post_condition `s.is_running() && s.is_suspended()`.
+
+__throws Any exception the `s.suspend(ec)` can throw.
+
+[endsect]
+////////////////////////////// ]
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_resumer Template Class `stopwatch_resumer<>`]
+
+Maintains the stopwatch resumed during the lifetime.
+
+ template<class Stopwatch>
+ class stopwatch_resumer
+ {
+ public:
+ typedef Stopwatch stopwatch;
+ stopwatch_resumer() = delete;
+ stopwatch_resumer(const stopwatch_resumer&) = delete;
+ stopwatch_resumer& operator=(const stopwatch_resumer&) = delete;
+ stopwatch_resumer(stopwatch & s);
+ ~stopwatch_resumer();
+ };
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c Constructor `stopwatch_resumer(stopwatch &s)`]
+
+__requires `s.is_running() && s.is_suspended()`.
+
+__effects Stores a reference `s` and as if `s.resume()`.
+
+__post_condition `s.is_running() && ! s.is_suspended()`.
+
+__throws Any exception the `s.resume()` can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:d Destructor `~stopwatch_resumer()`]
+
+__effects As if `s.suspend()`.
+
+__post_condition `s.is_running() && s.is_suspended()`.
+
+__throws Nothing.
+
+[endsect]
+
+[/ /////////////////////////////
+ stopwatch_resumer(stopwatch & s, system::error_code & ec);
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ec Constructor `stopwatch_resumer(stopwatch &s, system::error_code &ec)`]
+
+__requires `s.is_running() && s.is_suspended()`.
+
+__effects Stores a reference `s` and as if `s.resume(ec)`.
+
+__post_condition `s.is_running() && ! s.is_suspended()`.
+
+__throws Any exception the `s.resume(ec)` can throw.
+
+[endsect]
+////////////////////////////// ]
+
+[endsect] [/ class ]
+
+[endsect] [/ header ]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:dont_start_hpp Header `<boost/chrono/stopwatches/dont_start.hpp>`]
+[/==================================================]
+
+ namespace boost
+ {
+ namespace chrono
+ {
+ struct dont_start_t;
+ static const dont_start_t dont_start;
+ }
+ }
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:dont_start_t Class `dont_start_t`]
+
+Type used to don't start a Stopwatch at construction time.
+
+ struct dont_start_t { };
+
+[endsect] [/ class ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:dont_start Variable `dont_start`]
+
+Instance used to don't start a Stopwatch at construction time.
+
+ static const dont_start_t dont_start = { };
+
+[endsect] [/ var ]
+[endsect] [/ header ]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:strict_stopwatch_hpp Header `<boost/chrono/stopwatches/strict_stopwatch.hpp>`]
+[/==================================================]
+
+ namespace boost {
+ namespace chrono {
+ template <class __Clock=high_resolution_clock>
+ class strict_stopwatch;
+
+ // useful typedefs
+ typedef <see above> system_strict_stopwatch;
+ #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
+ typedef <see above> steady_strict_stopwatch;
+ #endif
+ typedef <see above> high_resolution_strict_stopwatch;
+ }}
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:strict_stopwatch Template Class `strict_stopwatch<>`]
+
+Knowing how long a part of a program takes to execute is useful in both test and production environments.
+A __strict_stopwatch` object measures elapsed time. It is recommended to use it with clocks that measure wall clock rather than CPU time since the intended use is performance measurement on systems where total elapsed time is more important than just process or CPU time.
+
+The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
+accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
+
+`strict_stopwatch <>` is a model of a __strict_stopwatch_concept.
+
+ template <class __Clock> class strict_stopwatch {
+ public:
+ typedef Clock clock;
+ typedef typename Clock::duration duration;
+ typedef typename Clock::time_point time_point;
+
+ strict_stopwatch( );
+ ~strict_stopwatch();
+
+ duration elapsed( );
+
+ };
+
+Only the specificities of this class are documented here. See __strict_stopwatch_concept for the common parts.
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c1 Constructor `strict_stopwatch()`]
+
+ strict_stopwatch();
+
+__effects constructs and starts the strict_stopwatch.
+
+__throws Any exception the `Clock::now()`can throw.
+
+[endsect]
+
+[/
+ explicit strict_stopwatch( system::error_code & ec );
+ duration elapsed( system::error_code & ec );
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c2 Constructor `strict_stopwatch( system::error_code &)`]
+
+ explicit strict_stopwatch( system::error_code & ec = throws() );
+
+__effects constructs and starts the strict_stopwatch.
+
+__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
+
+[endsect]
+]
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:typedefs `strict_stopwatch` useful typedefs]
+
+The following typedef are provided as syntactic sugar.
+
+ typedef strict_stopwatch< boost::chrono::system_clock > system_strict_stopwatch;
+ #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
+ typedef strict_stopwatch< boost::chrono:: steady_clock > steady_strict_stopwatch;
+ #endif
+ typedef strict_stopwatch< boost::chrono:: high_resolution_clock > high_resolution_strict_stopwatch;
+
+[endsect] [/ typedefs]
+[endsect] [/ header ]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:stopwatch_hpp Header `<boost/chrono/stopwatches/stopwatch.hpp>`]
+[/==================================================]
+
+ namespace boost {
+ namespace chrono {
+ template<typename __Clock=high_resolution_clock, typename __LapsCollector=no_memory<typename Clock::duration> >
+ class stopwatch;
+
+ // useful typedefs
+ typedef <see above> system_stopwatch;
+ #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
+ typedef <see above> steady_stopwatch;
+ #endif
+ typedef <see above> high_resolution_stopwatch;
+ }}
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch Template Class `stopwatch<>`]
+
+A __stopwatch is a model of __Stopwatch taking as parameters the __Clock and the __LapsCollector.
+
+The main difference respect to a __strict_stopwatch is that the user can stop it.
+
+Each sequence of start-stop results in a new elapsed duration sample that is provided to the __LapsCollector.
+It is up to the __LapsCollector to do whatever it wants with each sample.
+
+Even if it is preferable to use process or thread wide clocks, the default of the Clock parameter is high_resolution_clock,
+as it is the single one ensured on all platforms.
+
+The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
+accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
+
+`stopwatch <>` is a model of a __Stopwatch.
+
+ template<typename Clock, typename LapsCollector >
+ class stopwatch
+ {
+ public:
+ typedef Clock clock;
+ typedef LapsCollector laps_collector;
+ typedef typename Clock::duration duration;
+ typedef typename Clock::time_point time_point;
+ typedef typename Clock::rep rep;
+ typedef typename Clock::period period;
+ BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady;
+
+ stopwatch();
+ explicit stopwatch(const dont_start_t&) noexcept;
+ explicit stopwatch(laps_collector const& coll);
+ stopwatch(laps_collector const& acc, const dont_start_t&);
+ ~stopwatch();
+
+ void restart();
+ void start();
+ void stop();
+ bool is_running() const;
+
+ /**
+ * Elapsed time getter for the current lap.
+ *
+ * Returns: the elapsed time since the last start if no internal error occur.
+ *
+ */
+ duration elapsed_current_lap() const;
+
+
+ duration elapsed() const;
+ /**
+ * Elapsed time for the last lap.
+ *
+ * Returns: the elapsed time of the last lap.
+ *
+ */
+ duration last() const;
+
+ void reset();
+ laps_collector const& get_laps_collector() const noexcept;
+
+ typedef stopwatch_runner<stopwatch<Clock, LapsCollector> > scoped_run;
+ typedef stopwatch_stopper<stopwatch<Clock, LapsCollector> > scoped_stop;
+
+ };
+
+
+Only the specificities of this class are documented here. See __Stopwatch for the common parts.
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c Constructor `stopwatch()`]
+
+ stopwatch();
+
+__effects constructs and starts the stopwatch.
+
+__post_conditions: `is_running()`.
+
+__throws Any exception the `Clock::now()`can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ns Constructor `stopwatch( const dont_start_t& )`]
+
+ explicit stopwatch(const dont_start_t&) noexcept;
+
+__effects constructs and not starts the stopwatch.
+
+__post_conditions: `! is_running()`.
+
+__throws Nothing`
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_coll Constructor `stopwatch(laps_collector const&)`]
+
+ explicit stopwatch(laps_collector const& coll);
+
+__effects constructs copying the laps collector and starts the stopwatch.
+
+__post_conditions: `is_running()`.
+
+__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_coll_ns Constructor `stopwatch(laps_collector const&, const dont_start_t&)`]
+
+ stopwatch(laps_collector const& acc, const dont_start_t&);
+
+__effects constructs copying the laps collector and don't starts the stopwatch.
+
+__post_conditions: `! is_running()`.
+
+__throws Any exception the __LapsCollector copy can throw`
+
+[endsect]
+
+
+
+
+
+[/
+
+ explicit stopwatch(system::error_code & ec);
+ stopwatch(laps_collector const& acc, system::error_code & ec);
+ void restart(system::error_code & ec);
+ void start(system::error_code & ec);
+ void stop(system::error_code & ec);
+ /**
+ * Elapsed time getter for the current lap.
+ *
+ * Effects: Assign the error code if any internal error occur while retrieving the current time.
+ *
+ * Returns: the elapsed time since the start if no internal error occur.
+ *
+ */
+ duration elapsed_current_lap(system::error_code & ec) const;
+ duration elapsed(system::error_code & ec) const;
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ec Constructor `stopwatch( system::error_code &ec)`]
+
+ explicit stopwatch( system::error_code & ec = throws() );
+
+__effects constructs and starts the stopwatch.
+
+__post_conditions: `ec || is_running()`.
+
+__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
+
+[endsect]
+]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_coll_ec Constructor `stopwatch(laps_collector const&, system::error_code &)`]
+
+ explicit stopwatch(laps_collector const& acc, system::error_code & ec);
+
+__effects constructs copying the laps collector and starts the stopwatch. Assign the error code if any internal error occur while retrieving the current time.
+
+__post_conditions: `ec || is_running()`.
+
+__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw when `ec` is `throws()`
+
+[endsect]
+
+]
+
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:typedefs `stopwatch` useful typedefs]
+
+The following typedef are provided as syntactic sugar.
+
+ typedef stopwatch< boost::chrono::system_clock > system_stopwatch;
+ #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
+ typedef stopwatch< boost::chrono:: steady_clock > steady_stopwatch;
+ #endif
+ typedef stopwatch< boost::chrono:: high_resolution_clock > high_resolution_stopwatch;
+
+[endsect] [/ typedefs]
+[endsect] [/ header ]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:suspendable_stopwatch_hpp Header `<boost/chrono/stopwatches/suspendable_stopwatch.hpp>`]
+[/==================================================]
+
+ namespace boost {
+ namespace chrono {
+ template<typename __Clock=high_resolution_clock, typename __LapsCollector=no_memory<typename Clock::duration> >
+ class suspendable_stopwatch;
+
+ // useful typedefs
+ typedef <see above> system_suspendable_stopwatch;
+ #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
+ typedef <see above> steady_suspendable_stopwatch;
+ #endif
+ typedef <see above> high_resolution_suspendable_stopwatch;
+ }}
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:suspendable_stopwatch Template Class `suspendable_stopwatch<>`]
+
+A __suspendable_stopwatch is a model of __SuspendableStopwatch taking as parameters the __Clock and the __LapsCollector.
+
+The main difference respect to a __stopwatch is that the user can suspend/resume it.
+
+Each sequence of start-stop results in a new elapsed duration sample that is provided to the __LapsCollector.
+This lap can be suspended/resumed.
+
+Even if it is preferable to use process or thread wide clocks, the default of the Clock parameter is high_resolution_clock,
+as it is the single one ensured on all platforms.
+
+The maximum measurable elapsed time depends on the __Clock parameter. The accuracy of timings depends on the
+accuracy of timing information provided the __Clock, and this could varies a great deal from one clock to another.
+
+`suspendable_stopwatch<>` is a model of a __SuspendableStopwatch.
+
+ template<typename Clock, typename LapsCollector >
+ class suspendable_stopwatch
+ {
+ public:
+ typedef Clock clock;
+ typedef LapsCollector laps_collector;
+ typedef typename Clock::duration duration;
+ typedef typename Clock::time_point time_point;
+ typedef typename Clock::rep rep;
+ typedef typename Clock::period period;
+ BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady;
+
+ suspendable_stopwatch();
+ explicit suspendable_stopwatch(const dont_start_t&) noexcept;
+ explicit suspendable_stopwatch(laps_collector const& coll);
+ suspendable_stopwatch(laps_collector const& acc, const dont_start_t&);
+
+ ~suspendable_stopwatch();
+
+ void restart();
+ void start();
+ void stop();
+ void suspend();
+ void resume();
+ void reset();
+
+ bool is_running() const;
+ bool is_elapsed() const;
+ duration elapsed_current_lap() const;
+ duration elapsed() const;
+ duration last() const;
+ laps_collector const& get_laps_collector() const noexcept;
+
+ typedef stopwatch_runner<suspendable_stopwatch<Clock, LapsCollector> > scoped_run;
+ typedef stopwatch_stopper<suspendable_stopwatch<Clock, LapsCollector> > scoped_stop;
+ typedef stopwatch_suspender<suspendable_stopwatch<Clock, LapsCollector> > scoped_suspend;
+ typedef stopwatch_resumer<suspendable_stopwatch<Clock, LapsCollector> > scoped_resume;
+
+ };
+
+
+Only the specificities of this class are documented here. See __Stopwatch for the common parts.
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c Constructor `suspendable_stopwatch()`]
+
+ suspendable_stopwatch();
+
+__effects constructs and starts the stopwatch.
+
+__post_conditions: `is_running() && ! is_suspended()`.
+
+__throws Any exception the `Clock::now()`can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ns Constructor `suspendable_stopwatch( const dont_start_t& )`]
+
+ explicit suspendable_stopwatch(const dont_start_t&) noexcept;
+
+__effects constructs and not starts the stopwatch.
+
+__post_conditions: `! is_running() && ! is_suspended()`.
+
+__throws Nothing`
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_coll Constructor `suspendable_stopwatch(laps_collector const&)`]
+
+ explicit suspendable_stopwatch(laps_collector const& coll);
+
+__effects constructs copying the laps collector and starts the stopwatch.
+
+__post_conditions: `is_running() && ! is_suspended()`.
+
+__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw.
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_coll_ns Constructor `suspendable_stopwatch(laps_collector const&, const dont_start_t&)`]
+
+ suspendable_stopwatch(laps_collector const& acc, const dont_start_t&);
+
+__effects constructs copying the laps collector and don't starts the stopwatch.
+
+__post_conditions: `! is_running() && ! is_suspended()`.
+
+__throws Any exception the __LapsCollector copy can throw`
+
+[endsect]
+
+
+[/
+
+ explicit suspendable_stopwatch(system::error_code & ec);
+ suspendable_stopwatch(laps_collector const& acc, system::error_code & ec);
+ void restart(system::error_code & ec);
+ void start(system::error_code & ec);
+ void stop(system::error_code & ec);
+ void suspend(system::error_code & ec);
+ void resume(system::error_code & ec);
+ void reset(system::error_code & ec);
+ duration elapsed_current_lap(system::error_code & ec) const;
+ duration elapsed(system::error_code & ec) const;
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_ec Constructor `suspendable_stopwatch( system::error_code &ec)`]
+
+ explicit suspendable_stopwatch( system::error_code & ec = throws() );
+
+__effects constructs and starts the stopwatch.
+
+__post_conditions: `is_running() && ! is_suspended()`.
+
+__throws Any exception the `Clock::now()`can throw when `ec` is `throws()`
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:c_coll_ec Constructor `suspendable_stopwatch(laps_collector const&, system::error_code &)`]
+
+ explicit suspendable_stopwatch(laps_collector const& acc, system::error_code & ec);
+
+__effects constructs copying the laps collector and starts the stopwatch. Assign the error code if any internal error occur while retrieving the current time.
+
+__post_conditions: `ec || (is_running() && ! is_suspended())`.
+
+__throws Any exception the `Clock::now()` or the __LapsCollector copy can throw when `ec` is `throws()`
+
+[endsect]
+]
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:typedefs `suspendable_stopwatch` useful typedefs]
+
+The following typedef are provided as syntactic sugar.
+
+ typedef suspendable_stopwatch< boost::chrono::system_clock > system_suspendable_stopwatch;
+ #ifdef __BOOST_CHRONO_HAS_CLOCK_STEADY
+ typedef suspendable_stopwatch< boost::chrono:: steady_clock > steady_suspendable_stopwatch;
+ #endif
+ typedef suspendable_stopwatch< boost::chrono:: high_resolution_clock > high_resolution_suspendable_stopwatch;
+
+[endsect] [/ typedefs]
+[endsect] [/ header ]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:collectors Collectors]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:no_memory_hpp Header `<boost/chrono/stopwatches/collectors/no_memory.hpp>`]
+[/==================================================]
+
+ namespace boost
+ {
+ namespace chrono
+ {
+
+ template<typename Duration>
+ struct no_memory;
+
+ }
+ }
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:no_memory Class `no_memory`]
+
+ template<typename Duration>
+ struct no_memory
+ {
+ typedef Duration duration;
+
+ duration elapsed() const;
+ duration last() const;
+ void store(duration const& );
+ void reset();
+
+ };
+
+[endsect]
+
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:last_lap_hpp Header `<boost/chrono/stopwatches/collectors/last_lap.hpp>`]
+[/==================================================]
+
+ namespace boost
+ {
+ namespace chrono
+ {
+
+ template<typename Duration>
+ struct last_lap;
+
+ }
+ }
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:last_lap Class `last_lap`]
+
+ template<typename Duration>
+ struct last_lap
+ {
+ typedef Duration duration;
+ duration elapsed() const;
+ duration last() const;
+ void store(duration const& d);
+ void reset();
+
+ };
+
+[endsect]
+
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:laps_accumulator_set_hpp Header `<boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp>`]
+[/==================================================]
+
+ namespace boost
+ {
+ namespace chrono
+ {
+
+ template<
+ typename Duration,
+ typename Features = accumulators::features<accumulators::tag::count,
+ accumulators::tag::sum, accumulators::tag::min,
+ accumulators::tag::max, accumulators::tag::mean>,
+ typename Weight = void>
+ struct laps_accumulator_set;
+
+ }
+ }
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:laps_accumulator_set Class `laps_accumulator_set`]
+
+ template<
+ typename Duration,
+ typename Features = accumulators::features<accumulators::tag::count,
+ accumulators::tag::sum, accumulators::tag::min,
+ accumulators::tag::max, accumulators::tag::mean>,
+ typename Weight = void>
+ struct laps_accumulator_set : last_lap<Duration>
+ {
+ typedef Duration duration;
+ typedef accumulators::accumulator_set<typename duration::rep, Features,
+ Weight> storage_type;
+
+ duration elapsed() const;
+ void store(duration const& d);
+ void reset();
+ storage_type const& accumulator_set() const;
+
+
+ };
+
+[endsect]
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:laps_sequence_container_hpp Header `<boost/chrono/stopwatches/collectors/laps_sequence_container.hpp>`]
+[/==================================================]
+
+ namespace boost
+ {
+ namespace chrono
+ {
+
+ template<
+ typename Duration,
+ typename SequenceContainer = std::list<Duration>
+ >
+ struct laps_sequence_container;
+
+ }
+ }
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:laps_sequence_container Class `laps_sequence_container`]
+
+ template<
+ typename Duration,
+ typename SequenceContainer = std::list<Duration>
+ >
+ struct laps_sequence_container
+ {
+ typedef Duration duration;
+ typedef SequenceContainer storage_type;
+ typedef typename SequenceContainer::iterator iterator;
+ typedef typename SequenceContainer::const_iterator const_iterator;
+
+ duration elapsed() const;
+ duration last() const;
+ storage_type const& container() const;
+ void store(duration const& d);
+ void reset();
+ };
+
+[endsect]
+[endsect] [/ header ]
+[endsect] [/ collectors ]
+[endsect] [/ stopwatches]
+
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopclocks Stopclocks]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:formatter_req `Formatter` Requirements]
+
+A Formatter outputs on a given ostream a formatted string combining informations from a __StrictStopwatch, the format and the double precision.
+
+A Formatter must meet the requirements in the following Table.
+
+In this table `F` denote a Formatter type, `f` is an instance of `F`, `p` is an `int`, `ds` is a `__duration_style`, and `os` is a `F::ostream_type`.
+
+[table Formatter Requirements
+ [[expression] [return type] [operational semantics]]
+ [[`F::char_type`] [The associated char type.] [-]]
+ [[`F::string_type`] [The associated string type.] [-]]
+ [[`F::format_type`] [The associated format type ] [-]]
+ [[`F::ostream_type`] [The associated output stream type ] [-]]
+ [[`F::`] [A model of ] [-]]
+ [[`F()`] [F&&] [Default constructible.]]
+ [[`F(os)`] [F&&] [Explicit Constructible from an std::basic_ostream.]]
+ [[`F(os)`] [F&&] [Explicit Constructible from an std::basic_ostream.]]
+ [[`f.set_precision(p)`] [`-`] [Sets the precision used when displaying a double.]]
+ [[`f.set_duration_style(ds)`] [`-`] [Sets the duration style used when displaying a duration.]]
+ [[`f(s)`] [`S::time_point`] [outputs on `os` a formatted string combining informations from the Stopwatch `s`, the format `f` and the double precision `p`.]]
+]
+
+
+Models of `Formatter`:
+
+
+[endsect] [/section:formatter_req]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopclock_req `StopClock` Requirements]
+
+A Stopclock is a Stopwatch that is able to make reports associated to the collected samples.
+Stopclocks ensure that a report is done once and only once.
+
+A Stopclock must meet the requirements in the following Table.
+In this table `S` denote a Stopclock type and `s` is an instance of `S`, `fmt` `f` is `const S::char_type *` or `const S::string_type &` or `S::format_type`.
+
+[table Stopclock Requirements
+ [[expression] [return type] [operational semantics]]
+ [[`S::stopwatch_type`] [A model of __Stopwatch] [-]]
+ [[`S::formater_type`] [A model of __Formater] [-]]
+
+ [[`S(fmt)`] [S&&] [Constructor with specific format.]]
+ [[`s::report()`] [`-`] [Makes a report of the stopclock samples.]]
+ [[`s::reported()`] [`bool`] [States if a report has already been done.]]
+]
+
+
+Models of `Stopclock`:
+
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:stopwatch_reporter_hpp Header `<boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp>`]
+[/==================================================]
+
+ namespace boost
+ {
+ namespace chrono
+ {
+
+ template<
+ class CharT,
+ class Stopwatch,
+ class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
+ class basic_stopwatch_reporter;
+
+ template<
+ class Stopwatch,
+ class Formatter = typename basic_stopwatch_reporter_default_formatter<char, Stopwatch>::type>
+ class stopwatch_reporter;
+
+ template<class Stopwatch, class Formatter>
+ struct basic_stopwatch_reporter_default_formatter<char, stopwatch_reporter<Stopwatch, Formatter> >;
+
+ template<
+ class Stopwatch,
+ class Formatter = typename basic_stopwatch_reporter_default_formatter<wchar_t, Stopwatch>::type>
+ class wstopwatch_reporter;
+
+ template<class Stopwatch, class Formatter>
+ struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >;
+
+ }
+ }
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:basic_stopwatch_reporter Template Class `basic_stopwatch_reporter`]
+
+ template<
+ class CharT,
+ class Stopwatch,
+ class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> >
+ class basic_stopwatch_reporter: public Stopwatch
+ {
+ public:
+ typedef typename Stopwatch::clock clock;
+ typedef Stopwatch stopwatch_type;
+ typedef Formatter formatter_type;
+
+ basic_stopwatch_reporter(const basic_stopwatch_reporter&) = delete;
+ basic_stopwatch_reporter& operator=(const basic_stopwatch_reporter&) = delete;
+
+ basic_stopwatch_reporter() noexcept;
+ explicit basic_stopwatch_reporter(system::error_code & ec);
+ explicit basic_stopwatch_reporter(const dont_start_t& tag) noexcept;
+ explicit basic_stopwatch_reporter(const typename Formatter::char_type* fmt);
+ explicit basic_stopwatch_reporter(typename Formatter::string_type const& fmt);
+ explicit basic_stopwatch_reporter(formatter_type fmt);
+
+ ~basic_stopwatch_reporter() noexcept;
+
+ bool reported() const;
+ formatter_type& format();
+
+ void report() noexcept;
+
+ protected:
+ formatter_type formatter_;
+ bool reported_;
+
+ };
+
+[endsect]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_reporter Template Class `stopwatch_reporter`]
+
+ template<class Stopwatch, class Formatter>
+ class stopwatch_reporter: public basic_stopwatch_reporter<char, Stopwatch, Formatter>
+ {
+ public:
+ typedef typename Stopwatch::clock clock;
+ typedef Stopwatch stopwatch_type;
+ typedef Formatter formatter_type;
+
+ stopwatch_reporter(const stopwatch_reporter&) = delete;
+ stopwatch_reporter& operator=(const stopwatch_reporter&) = delete;
+ stopwatch_reporter();
+ explicit stopwatch_reporter(system::error_code & ec);
+ explicit stopwatch_reporter(const dont_start_t& tag) noexcept;
+ explicit stopwatch_reporter(formatter_type const& fmt);
+ explicit stopwatch_reporter(const typename Formatter::char_type* fmt);
+ explicit stopwatch_reporter(typename Formatter::string_type const& fmt);
+
+ typedef stopwatch_runner<stopwatch_reporter<Stopwatch, Formatter> > scoped_run;
+ typedef stopwatch_stopper<stopwatch_reporter<Stopwatch, Formatter> > scoped_stop;
+ typedef stopwatch_suspender<stopwatch_reporter<Stopwatch, Formatter> > scoped_suspend;
+ typedef stopwatch_resumer<stopwatch_reporter<Stopwatch, Formatter> > scoped_resume;
+
+ };
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:stopwatch_reporter_ps Partial Specialization `basic_stopwatch_reporter_default_formatter<char_t, stopwatch_reporter<Stopwatch, Formatter> >`]
+
+ template<class Stopwatch, class Formatter>
+ struct basic_stopwatch_reporter_default_formatter<char_t, stopwatch_reporter<Stopwatch, Formatter> >
+ {
+ typedef Formatter type;
+ };
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:wstopwatch_reporter Template Class `wstopwatch_reporter`]
+
+ template<class Stopwatch, class Formatter>
+ class wstopwatch_reporter: public basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter>
+ {
+ public:
+ typedef typename Stopwatch::clock clock;
+ typedef Stopwatch stopwatch_type;
+ typedef Formatter formatter_type;
+
+ wstopwatch_reporter(const wstopwatch_reporter&) = delete;
+ wstopwatch_reporter& operator=(const wstopwatch_reporter&) = delete;
+ wstopwatch_reporter();
+ explicit wstopwatch_reporter(system::error_code & ec);
+ explicit wstopwatch_reporter(const dont_start_t& tag) noexcept;
+
+ explicit wstopwatch_reporter(formatter_type const& fmt);
+ explicit wstopwatch_reporter(const typename Formatter::char_type* fmt);
+ explicit wstopwatch_reporter(typename Formatter::string_type const& fmt);
+ typedef stopwatch_runner<wstopwatch_reporter<Stopwatch, Formatter> > scoped_run;
+ typedef stopwatch_stopper<wstopwatch_reporter<Stopwatch, Formatter> > scoped_stop;
+ typedef stopwatch_suspender<wstopwatch_reporter<Stopwatch, Formatter> > scoped_suspend;
+ typedef stopwatch_resumer<wstopwatch_reporter<Stopwatch, Formatter> > scoped_resume;
+
+ };
+
+
+[endsect]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:wstopwatch_reporter_ps Partial Specialization `basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >`]
+
+ template<class Stopwatch, class Formatter>
+ struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> >
+ {
+ typedef Formatter type;
+ };
+
+[endsect]
+
+
+[endsect] [/ header ]
+
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:strict_stopclock_hpp Header `<boost/chrono/stopwatches/reporters/strict_stopclock.hpp>`]
+[/==================================================]
+
+
+ namespace boost
+ {
+ namespace chrono
+ {
+
+ template<class CharT, typename Clock, class Formatter>
+ class basic_strict_stopclock;
+
+ template<typename Clock=high_resolution_clock,
+ class Formatter = typename basic_stopwatch_reporter_default_formatter<char, strict_stopwatch<Clock> >::type>
+ class strict_stopclock;
+
+ template<class Stopwatch, class Formatter>
+ struct basic_stopwatch_reporter_default_formatter<char, strict_stopclock<Stopwatch, Formatter> >
+ {
+ typedef Formatter type;
+ };
+
+ } // namespace chrono
+ } // namespace boost
+
+
+[section:basic_strict_stopclock Template Class `basic_strict_stopclock<>`]
+
+ template<class CharT, typename Clock, class Formatter>
+ class basic_strict_stopclock: public basic_stopwatch_reporter<CharT, strict_stopwatch<Clock>, Formatter>
+ {
+ public:
+ typedef basic_stopwatch_reporter<CharT, strict_stopwatch<Clock>, Formatter> base_type;
+ typedef Clock clock;
+ typedef strict_stopwatch<Clock> stopwatch;
+ typedef Formatter formatter_type;
+
+ basic_strict_stopclock();
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ explicit basic_strict_stopclock(system::error_code & ec);
+#endif
+
+ explicit basic_strict_stopclock(formatter_type const& fmt);
+
+ explicit basic_strict_stopclock(const typename Formatter::char_type* fmt);
+ explicit basic_strict_stopclock(typename Formatter::string_type const& fmt);
+
+ protected:
+
+ basic_strict_stopclock(const basic_strict_stopclock&) = delete;
+ basic_strict_stopclock& operator=(const basic_strict_stopclock&) = delete;
+ };
+
+[endsect] [/ class ]
+[section:strict_stopclock Template Class `strict_stopclock<>`]
+
+ template<typename Clock, class Formatter>
+ class strict_stopclock: public basic_strict_stopclock<char, Clock, Formatter>
+ {
+ public:
+ typedef Clock clock;
+ typedef typename base_type::stopwatch stopwatch;
+ typedef Formatter formatter_type;
+
+ strict_stopclock()
+ {
+ }
+
+#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
+ explicit strict_stopclock(system::error_code & ec);
+#endif
+ explicit strict_stopclock(formatter_type const& fmt);
+ explicit strict_stopclock(const typename Formatter::char_type* fmt);
+ explicit strict_stopclock(typename Formatter::string_type const& fmt);
+
+ protected:
+
+ strict_stopclock(const strict_stopclock&) = delete;
+ strict_stopclock& operator=(const strict_stopclock&) = delete;
+ };
+
+[endsect] [/ class ]
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:stopclock_hpp Header `<boost/chrono/stopwatches/reporters/stopclock.hpp>`]
+[/==================================================]
+
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[section:formatters Formatters]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:base_formatter_hpp Header `<boost/chrono/stopwatches/formatters/base_formatter.hpp>`]
+[/==================================================]
+
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:elapsed_formatter_hpp Header `<boost/chrono/stopwatches/formatters/elapsed_formatter.hpp>`]
+[/==================================================]
+
+[endsect] [/ header ]
+[//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////]
+[/==================================================]
+[section:accumulator_set_formatter_hpp Header `<boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp>`]
+[/==================================================]
+
+[endsect] [/ header ]
+[endsect] [/ formatters ]
+[endsect] [/section:stopclocks]

Added: trunk/libs/chrono/doc/stopwatches/tutorial.qbk
==============================================================================
--- (empty file)
+++ trunk/libs/chrono/doc/stopwatches/tutorial.qbk 2012-09-06 19:53:24 EDT (Thu, 06 Sep 2012)
@@ -0,0 +1,369 @@
+[/
+ / Copyright (c) 2009-20010 Vicente J. Botet Escriba
+ /
+ / Distributed under the Boost Software License, Version 1.0. (See accompanying
+ / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ /]
+
+
+[/================]
+[/section Tutorial]
+[/================]
+
+[/=================================]
+[section Stopwatches and Stopclocks]
+[/=================================]
+
+At the user level, the main use case of measuring the elapsed time is to report these measures on the display. For example
+
+ using namespace boost::chrono;
+
+ int f1(long j) {
+ strict_stopwatch<> sw;
+
+ for ( long i = 0; i < j; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ std::cout << sw.elapsed() << std::endl;
+ return 0;
+ }
+ int main() {
+ f1(100000);
+ f1(200000);
+ f1(300000);
+ return 0;
+ }
+
+Could produce the following output
+
+ 0.006s
+ 0.011s
+ 0.017s
+
+__stopwatch is a template class with a Clock as template parameter. The default __Clock is the __high_resolution_clock.
+
+We can replace the lines
+
+ strict_stopwatch <> sw;
+
+ ...
+ std::cout << sw.elapsed() << std::endl;
+
+using the __stopwatch_reporter`<>` class. This class provides a run time reporting package that can be invoked in a single line of code to report the usage of a __Clock. For example
+
+ using namespace boost::chrono;
+
+ int f1(long j) {
+ __stopwatch_reporter<__strict_stopwatch <> > _;
+
+ for ( long i = 0; i < j; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+ }
+ int main() {
+ f1(100000);
+ f1(200000);
+ f1(300000);
+ return 0;
+ }
+
+Which produce the same kind of output.
+
+__stopwatch_reporter is a template class with a __Stopwatch and a __Formatter as template parameter.
+
+We can use even a shorter line using the __stopclock class, which allows to replace
+
+ __stopwatch_reporter<__strict_stopwatch<> > _;
+
+by
+
+ __strict_stopclock<> _;
+
+[section:accumulators Stopwatches accumulation and statistics]
+
+The preceding stopwatch manage only with a measure. It is also interesting to have an statisitical view of these times,
+for example the sum, min, max and mean. __laps_stopwatch`<>` associates an accumulator with a __stopwatch__, so we are able to retrieve any statistical feature Boost.Accumulator provides.
+
+For example
+
+ using namespace boost::chrono;
+
+ int f1(long j) {
+ static __stopwatch_reporter<__laps_stopwatch<> > sw;
+ __stopwatch_reporter<__laps_stopwatch<> >::scoped_run _(sw);
+
+ for ( long i = 0; i < j; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+ }
+ int main() {
+ f1(100000);
+ f1(200000);
+ f1(300000);
+ return 0;
+ }
+
+Will produce the following output
+
+ 3 times, sum=0.034s, min=0.006s, max=0.017s, mean=0.011s
+
+
+[endsect]
+
+
+
+[section:function How can I prefix each report with `BOOST_CURRENT_FUNCTION` function signature?]
+
+You will need to give a specific format to your __stopclock. You just need to concatenate your specific pattern to the default_format of the formatter.
+
+For example, for a __stopclock_accumulator the default formatter is __stopwatch_accumulator_formatter, you will need to do something like:
+
+ static __stopclock_accumulator<> acc(
+ std::string(BOOST_CURRENT_FUNCTION) + ": "
+ + __stopwatch_accumulator_formatter::default_format()
+ );
+ __stopclock_accumulator<>::scoped_run _(acc);
+
+
+Some of you will say that this is too long to type just to get the a report. You can of course define your own macro as
+
+ #define REPORT_FUNCTION_ACCUMULATED_LIFETIME\
+ static boost::stopwatches::__stopclock_accumulator<> \
+ BOOST_JOIN(_accumulator_, __LINE__)_
+ ( std::string(BOOST_CURRENT_FUNCTION) + ": " + \
+ boost::stopwatches::__stopwatch_accumulator_formatter::default_format() \
+ ); \
+ boost::stopwatches::__stopclock_accumulator<>::scoped_run \
+ BOOST_JOIN(_accumulator_run_, __LINE__) \
+ (BOOST_JOIN(_accumulator_, __LINE__))
+
+
+With this macro you will just have to write
+
+ void foo()
+ {
+ REPORT_FUNCTION_ACCUMULATED_LIFETIME() ;
+ boost::this_thread::sleep(boost::posix_time::milliseconds(100));
+ // ...
+ }
+
+[endsect]
+
+[section:file_line How can I prefix each report with `__FILE__[__LINE__]` pattern?]
+
+When you want to prefix with the `__FILE__[__LINE__]` pattern you can follow the same technique as described below:
+
+ #define REPORT_LINE_ACCUMULATED_LIFETIME \
+ static __stopclock_accumulator<>
+ BOOST_JOIN(_accumulator_, __LINE__) \
+ ( std::string(__FILE__) + "[" + BOOST_STRINGIZE(__LINE__) + "] "
+ + __stopwatch_accumulator_formatter::default_format() \
+ ); \
+ __stopclock_accumulator<>::scoped_run \
+ BOOST_JOIN(_accumulator_run_, __LINE__)
+ (BOOST_JOIN(_accumulator_, __LINE__))
+
+Now you can mix fcntion and line reports as follows
+
+ void foo()
+ {
+ REPORT_FUNCTION_ACCUMULATED_LIFETIME;
+ boost::this_thread::sleep(boost::posix_time::milliseconds(100));
+ {
+ REPORT_LINE_ACCUMULATED_LIFETIME;
+ boost::this_thread::sleep(boost::posix_time::milliseconds(200));
+ }
+
+ }
+
+[endsect]
+
+[section:non_static_acc Can I use an stopclock accumulator which is not static?]
+
+The typical example of stopclock_accumulator is to get statistical measures of the time a function takes for each one of its calls.
+You can also use __stopclock_accumulator to get statistical measures of the time a given loop takes for each one of its laps.
+
+ __stopclock_accumulator<> acc(
+ std::string(__FILE__) + "[" + BOOST_STRINGIZE(__LINE__) + "] "
+ + __stopwatch_accumulator_formatter::default_format()
+ );
+ for (int i=0; i<N; i++) {
+ __stopclock_accumulator<>::scoped_run _(acc);
+ // ...
+ }
+
+
+[endsect]
+
+[section:suspend How can I suspend a stopwatch?]
+
+ #include <boost/stopwatches/stopwatch.hpp>
+ #include <cmath>
+ #include <boost/thread.hpp>
+
+
+ using namespace boost::stopwatches;
+ double res;
+ void f1(long j)
+ {
+ __stopwatch_reporter<__stopwatch__<> >:: _(BOOST_STOPWATCHES_STOPWATCH_FUNCTION_FORMAT);
+ for (long i =0; i< j; i+=1)
+ res+=std::sqrt( res+123.456L+i ); // burn some time
+ __stopwatch_reporter<__stopwatch__<> >::scoped_suspend s(_);
+ boost::this_thread::sleep(boost::posix_time::milliseconds(200));
+ }
+
+[endsect]
+
+[section:stats How to get specific statistics from stopwatches accumulator?]
+
+There are two use cases that coul need to change the statistics associated to a stopwatches accumulator:
+
+# We want to reduce the default reporting and we preffer to adapt the statistics to the reporting
+# We want to report other statistics of the samples
+
+For the first case we just need to change the accumulator_set and the format we want to get. Imagin we want to get only the count, sam and mean statistics, no need to calculate the min neither the max.
+
+ using namespace boost::accumulators;
+
+ typedef __stopwatch_reporter<__laps_stopwatch<__process_real_cpu_clock__,
+ accumulator_set<__process_real_cpu_clock__::rep,
+ features<
+ tag::count,
+ tag::sum,
+ tag::mean
+ >
+ >
+ > my_stopwatch_accumulator_reporter;
+
+ int f1(long j)
+ {
+ static my_stopwatch_accumulator_reporter acc("%c times, sum=%ss, mean=%as\n");
+ my_stopwatch_accumulator_reporter::scoped_run _(acc);
+
+ for ( long i = 0; i < j; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+ }
+
+But what would hapend if we haven't forced the format:
+
+ static my_stopwatch_accumulator_reporter acc;
+ my_stopwatch_accumulator_reporter::scoped_run _(acc);
+
+Unfortunately there is no error at compile time. Fortunately, the run-time execution is not undefined and will return 0 for the missing statistics.
+
+
+[endsect]
+
+[section Formatting]
+
+[section:other How can I make a specific formatter when the default do not satisfy my expectations]
+
+Imagine then that we want to report the `tag::variance(lazy)`. We will need to include the specific accumulator file
+
+ ...
+ #include <boost/accumulators/statistics/variance.hpp>
+ ...
+ typedef __stopwatch_reporter<__laps_stopwatch<__process_real_cpu_clock__,
+ accumulator_set<__process_real_cpu_clock__::rep,
+ features<
+ tag::count,
+ tag::sum,
+ tag::mean,
+ tag::variance(lazy)
+ >
+ >
+ > my_stopwatch_accumulator_reporter;
+
+But what happens if we add new statistics to the accumulator_set that are not taken in account by the default formatter? These statistics will simply be ignored. So we will need to define our own accumulator formatter.
+
+ typedef __stopwatch_reporter<__laps_stopwatch<__process_real_cpu_clock__,
+ accumulator_set<__process_real_cpu_clock__::rep,
+ features<
+ tag::count,
+ tag::sum,
+ tag::mean,
+ tag::variance(lazy)
+ >
+ >,
+ my_stopwatch_accumulator_formatter
+ > my_stopwatch_accumulator_reporter;
+
+Next follow the definition of a formatter taking care of count, sum, mean and variance
+
+ class my_stopwatch_accumulator_formatter {
+ public:
+ typedef std::string string_type;
+ typedef char char_type;
+ typedef std::ostream ostream_type;
+
+ static ostream_type & default_os() {return std::cout;}
+ static const char_type* default_format() {
+ return "%c times, sum=%ss, mean=%as, variance=%vs\n";
+ }
+ static int default_places() { return 3; }
+
+ template <class Stopwatch >
+ static void show_time( Stopwatch & stopwatch_, const char_type* format,
+ int places, ostream_type & os, system::error_code & ec)
+ {
+ typedef typename Stopwatch::duration duration_t;
+ typename Stopwatch::accumulator accumulator& acc = stopwatch_.accumulated();
+
+ boost::io::ios_flags_saver ifs( os );
+ os.setf( std::ios_base::fixed, std::ios_base::floatfield );
+ boost::io::ios_precision_saver ips( os );
+ os.precision( places );
+
+ for ( ; *format; ++format ) {
+ if ( *format != '%' || !*(format+1) || !std::strchr("acsv", *(format+1)) ) {
+ os << *format;
+ } else {
+ ++format;
+ switch ( *format ) {
+ case 's':
+ os << boost::chrono::duration<double>(
+ duration_t(accumulators::sum(acc))).count();
+ break;
+ case 'a':
+ os << (accumulators::count(acc)>0)
+ ? boost::chrono::__duration__<double>(duration_t(
+ duration_t::rep(accumulators::mean(acc)))).count()
+ : 0;
+ break;
+ case 'c':
+ os << accumulators::count(acc);
+ break;
+ case 'v':
+ os << (accumulators::count(acc)>0)
+ ? boost::chrono::__duration__<double>(duration_t(
+ duration_t::rep(accumulators::variance(acc)))).count()
+ : 0;
+ break;
+ default:
+ assert(0 && "my_stopwatch_accumulator_formatter internal logic error");
+ }
+ }
+ }
+ }
+ };
+
+
+
+[endsect]
+
+
+[endsect]
+[endsect]
+
+[/===============]
+[/section Examples]
+[/===============]
+
+
+
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk