|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59262 - in sandbox/chrono/libs/chrono: doc doc/html doc/html/boost_chrono doc/html/boost_chrono/appendices doc/html/boost_chrono/overview doc/html/boost_chrono/reference doc/html/boost_chrono/users_guide example test
From: vicente.botet_at_[hidden]
Date: 2010-01-24 18:54:08
Author: viboes
Date: 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
New Revision: 59262
URL: http://svn.boost.org/trac/boost/changeset/59262
Log:
Boost.Chrono: Version 0.3.2,
* updated documentation
* added test_thread_clock.cpp
* added suspendible_stopclock_example.cpp
Added:
sandbox/chrono/libs/chrono/example/suspendible_stopclock_example.cpp (contents, props changed)
sandbox/chrono/libs/chrono/test/test_thread_clock.cpp (contents, props changed)
Text files modified:
sandbox/chrono/libs/chrono/doc/chrono.qbk | 287 ++++++++++++++++++++++++-------
sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices.html | 4
sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/faq.html | 14 +
sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/history.html | 21 +-
sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/rationale.html | 8
sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/tickets.html | 56 +++++
sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/todo.html | 29 --
sandbox/chrono/libs/chrono/doc/html/boost_chrono/overview/motivation.html | 2
sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/cpp0x.html | 30 +++
sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/other_clocks.html | 2
sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_formatters.html | 20 +
sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_reporters.html | 2
sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatches.html | 2
sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide.html | 10
sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/getting_started.html | 22 +-
sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/tutorial.html | 352 ++++++++++++++++++++++++++++++++++-----
sandbox/chrono/libs/chrono/doc/html/index.html | 2
sandbox/chrono/libs/chrono/example/specific_stopwatch_accumulator_example.cpp | 12 +
sandbox/chrono/libs/chrono/test/Jamfile.v2 | 5
19 files changed, 690 insertions(+), 190 deletions(-)
Modified: sandbox/chrono/libs/chrono/doc/chrono.qbk
==============================================================================
--- sandbox/chrono/libs/chrono/doc/chrono.qbk (original)
+++ sandbox/chrono/libs/chrono/doc/chrono.qbk 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -436,9 +436,9 @@
Will produce the following output
-0.006s
-0.011s
-0.017s
+ 0.006s
+ 0.011s
+ 0.017s
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. `stopwatch_accumulator<>` associates an accumulator with a stopwatch, so we are able to retrieve any statistical feature Boost.Accumulator provides.
@@ -463,7 +463,7 @@
Will produce the following output
- 3 times, sum 0.034s, min 0.006s, max 0.017s, mean 0.011s
+ 3 times, sum=0.034s, min=0.006s, max=0.017s, mean=0.011s
It is also helpful if such timing information is broken down into real (wall clock) time, CPU time spent by the user, and CPU time spent by the operating system servicing user requests.
@@ -610,7 +610,7 @@
* MSVC 10.0
* MSVC 9.0 Express
-* MSVC 5.0
+* MSVC 8.0
[/* Intel 11.0]
@@ -656,12 +656,12 @@
Here is a complete program (stopclock_example.cpp):
- #include <boost/chrono/process_times.hpp>
+ #include <boost/chrono/stopclock.hpp>
#include <cmath>
int main()
{
- boost::chrono::stopclockstopclock<> t;
+ boost::chrono::stopclock<> t;
for ( long i = 0; i < 10000000; ++i )
std::sqrt( 123.456L ); // burn some time
@@ -681,27 +681,57 @@
[section Tutorial]
-[section thread clock]
-[endsect]
-
[section How to define a thread clock]
+On posix systems for which the macro _POSIX_THREAD_CPUTIME is defined we can get the time associated to a specific thread.
+
class thread_clock {
public:
- typedef boost::intmax_t rep;
- typedef boost::chrono::nanoseconds period;
- typedef boost::chrono::duration<rep, period> duration;
- typedef boost::chrono::time_point<Clock> time_point;
- static const bool is_monotonic = true;
-
- static time_point now() {
- // get the current thread
- // get the clock_id associated to the current thread
- // get the clock_t associated to the thread clock
- // transform to nanoseconds
- }
- };
+ typedef nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<process_real_cpu_clock> time_point;
+ static const bool is_monotonic = true;
+ static time_point now( ) {
+ // get the current thread
+ pthread_t pth=pthread_self(void);
+ // get the clock_id associated to the current thread
+ clockid_t clock_id;
+ pthread_getcpuclockid(pth, clock_id);
+ // get the timespec associated to the thread clock
+ struct timespec ts;
+ if ( ::clock_gettime( clock_id, &ts ) )
+ {
+ boost::throw_exception(
+ system::system_error( errno, system::system_category, "chrono::thread_clock" ));
+ }
+
+ // transform to nanoseconds
+ return time_point(duration(
+ static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+
+ }
+ static time_point now( system::error_code & ec ) {
+ // get the current thread
+ pthread_t pth=pthread_self(void);
+ // get the clock_id associated to the current thread
+ clockid_t clock_id;
+ pthread_getcpuclockid(pth, clock_id);
+ // get the timespec associated to the thread clock
+ struct timespec ts;
+ if ( ::clock_gettime( clock_id, &ts ) )
+ {
+ ec.assign( errno, system::system_category );
+ return time_point();
+ }
+ ec.clear();
+ // transform to nanoseconds
+ return time_point(duration(
+ static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+
+ }
+ };
[endsect]
[section How can I prefix each report with `BOOST_CURRENT_FUNCTION` function signature?]
@@ -722,7 +752,7 @@
static boost::chrono::stopclock_accumulator<> BOOST_JOIN(_boost_chrono_stopclock_accumulator_, __LINE__)( \
std::string(BOOST_CURRENT_FUNCTION) + ": " + boost::chrono::stopwatch_accumulator_formatter::default_format() \
); \
- boost::chrono::stopclock_accumulator<>::scoped_stop BOOST_JOIN(_boost_chrono_stopclock_accumulator_run_, __LINE__)(BOOST_JOIN(_boost_chrono_stopclock_accumulator_, __LINE__))
+ boost::chrono::stopclock_accumulator<>::scoped_run BOOST_JOIN(_boost_chrono_stopclock_accumulator_run_, __LINE__)(BOOST_JOIN(_boost_chrono_stopclock_accumulator_, __LINE__))
With this macro you will just ave
@@ -738,7 +768,7 @@
[section How can I prefix each report with `__FILE__[__LINE__]` pattern?]
-When you want to prefixx with the `__FILE__[__LINE__]` pattern you can follow the same technique as described below:
+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(_boost_chrono_stopclock_accumulator_, __LINE__)( \
@@ -760,6 +790,7 @@
}
[endsect]
+
[section 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 an also use stopclock_accumulator to get statistical measures of the time a given loop takes for each one of its laps.
@@ -795,14 +826,18 @@
[endsect]
-[section How get specific statistics from stopwatches accumulator]
+[section How to get specific statistics from stopwatches accumulator?]
- #include <boost/chrono/stopwatches.hpp>
- #include <cmath>
+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::chrono;
using namespace boost::accumulators;
- typedef stopwatch_accumulator<process_real_cpu_clock, kind::running,
+
+ typedef stopwatch_accumulator<process_real_cpu_clock,
accumulator_set<process_real_cpu_clock::rep,
features<
tag::count,
@@ -814,7 +849,7 @@
int f1(long j)
{
- static my_stopwatch_accumulator_reporter acc(BOOST_CHRONO_ACCUMULATOR_FUNCTION_FORMAT);
+ 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 )
@@ -822,18 +857,104 @@
return 0;
}
- int main()
- {
- f1(100000);
- f1(200000);
- f1(300000);
- return 0;
- }
+But wat 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 How can I make a specific formatter when the defaul do not satisfy my expectations]
+[section 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_accumulator<process_real_cpu_clock,
+ accumulator_set<process_real_cpu_clock::rep,
+ features<
+ tag::count,
+ tag::sum,
+ tag::mean,
+ tag::variance(lazy)
+ >
+ >
+ >::reporter 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 own own accumulator formatter.
+
+ typedef stopwatch_accumulator<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
+ >::reporter 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]
@@ -1183,6 +1304,9 @@
typename common_type<Rep1, Rep2>::type
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
+ template <class Rep1, class Rep2, class Period>
+ double operator/(const Rep1& s, const duration<Rep2, Period>& d);
+
// duration comparisons
template <class Rep1, class Period1, class Rep2, class Period2>
bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
@@ -1669,8 +1793,20 @@
[endsect]
+[section:duration_operator_d_3 Non-Member function `operator/(Rep1,duration)`]
+
+ template <class Rep1, class Rep2, class Period>
+ double operator/(const Rep1& s, const duration<Rep2, Period>& d);
+
+[*Remarks:] Let `CR` represent the `common_type` of `Rep1` and `Rep2`. This function will not participate in overload resolution unless both `Rep1` and `Rep2` are implicitly convertible to `CR`, and `Rep1` is not an instantiation of `duration`.
+
+[*Returns:] `CR(s)/duration<CR, Period>(d)`.
+
+[endsect]
+
[section:duration_operator_mod_1 Non-Member function `operator%(duration,Rep2)`]
+
template <class Rep1, class Period, class Rep2>
duration<typename common_type<Rep1, Rep2>::type, Period>
operator%(const duration<Rep1, Period>& d, const Rep2& s);
@@ -3281,15 +3417,18 @@
The default places is given by default_places and is 3.
-The default format is "%c times, sum=%ss, min=%ms, max=%Ms, mean=%as\\n", where
+The default format is "%c times, sum=%ss, min=%ms, max=%Ms, mean=%as, frequency=%fherzs, lifetime=%ls, percentage=%p\%\\n", where
* `%c` : the counter of the number of times the pair srat/stop has been called.
* `%s` : the sum of the samples of elapsed time between the call to start/stop.
* `%m` : the min of the samples of elapsed time between the call to start/stop.
* `%M` : the max of the samples of elapsed time between the call to start/stop.
* `%a` : the mean of the samples of elapsed time between the call to start/stop.
+* `%f` : the frequency of calls to start.
+* `%l` : the lifetime of the stopwatch_accumulator.
+* `%p` : the percentage of time spent by this stopwatch respect to its lifetime.
-The time is given using the suffix "s" following the System International d'Unites Std.
+The time is given using the suffix "s", the frequency is given using the suffix "herzs", both following the System International d'Unites Std.
[endsect]
@@ -4642,20 +4781,21 @@
[section:history Appendix A: History]
[/==================================]
-[section [*Version 0.3.2, January 24, 2010] ['New SuspendibleClock + Bug fixes]]
+[section [*Version 0.3.2, January 24, 2010] ['New SuspendibleClock, New frequency, lifetime and percentage stopwatch_accumulator features]]
[*Features:]
* Suspendible Clock concept + template class suspendible_clock<>
-* Added scope_suspend which will do nothing if the Clock is not a Suspendible Clock concept, and suspend/resume otherwise.
+* Added scope_suspend which do suspend/resume if the Clock is a model of Suspendible Clock concept, and nothing otherwise.
* Use of scope_suspend while reporting on stopwatch reporter
+* Added overloading for operator/(Integer/Duration)
+* Added frequency, lifetime and percentage to the default stopwatch_accumulator_formatter
[*Bug Fixes]
-
-* add static assertions to stopclock and stopclock_accumulator
+* Specific formatters doesn't works
[endsect]
-[section [*Version 0.3.1, January 20, 2010] ['New Allow wide characters + Bug fixes]]
+[section [*Version 0.3.1, January 20, 2010] ['New support for wide characters]]
[*Features:]
* Support for wide characters on formatters and stopclocks
@@ -4896,6 +5036,10 @@
Ask your operating system supplier. The results have been inspected with a debugger, and both for Windows and Linux, that's what the OS appears to be reporting at times.
+[heading Can I obtain statistics of the time elapsed between calls to a function?]
+
+The library do not provides this feature.
+
[endsect]
[/====================================================]
@@ -4997,6 +5141,26 @@
[table
[[Ticket] [Description] [Resolution] [State]]
+ [[0] [ Issues raised by Michael Marcin: In the past I've seen QueryPerformanceCounter give incorrect results,
+ especially with SpeedStep processors on laptops. This was many years ago and
+ might have been fixed by service packs and drivers.
+
+ Typically you check the results of QPC against GetTickCount to see if the
+ results are reasonable.
+ http://support.microsoft.com/kb/274323
+
+ I've also heard of problems with QueryPerformanceCounter in multi-processor
+ systems.
+
+ I know some people SetThreadAffinityMask to 1 for the current thread call
+ their QueryPerformance* functions then restore SetThreadAffinityMask. This
+ seems horrible to me because it forces your program to jump to another
+ physical processor if it isn't already on cpu0 but they claim it worked well
+ in practice because they called the timing functions infrequently.
+
+ In the past I have chosen to use timeGetTime with timeBeginPeriod(1) for
+ high resolution timers to avoid these issues.
+ ] [XXXX] [Open]]
[[1] [operator/ was ambiguous] [Disambiguate duration operator/] [Close]]
[[2] [CLOCK_MONOTONIC is not defined with cygwin/gcc 3.4] [Disable code when BOOST_CHRONO_HAS_CLOCK_MONOTONIC is not defined.] [Close]]
[[3] [result of metafunctions ratio_multiply and ratio_divide were not normalized ratios] [Use of the nested ratio typedef type on ratio arithmetic operations.] [Close]]
@@ -5018,12 +5182,16 @@
..\..\../boost/chrono/chrono.hpp:816: warning: suggest parentheses around '&&' within '||'
..\..\../boost/chrono/chrono.hpp:816: warning: suggest parentheses around '&&' within '||'] [???] [Open]]
[[19] [suspendible_clock_test don't works in my windows environement (issue with tss)] [XXXX] [Open]]
- [[#] [XXXX] [XXXX] [Close]]
- [[#] [XXXX] [XXXX] [Close]]
+ [[20] [Use of Specific formatters doesn't works] [XXXX] [Close]]
+
+ [[21] [boost/chrono/scoped_suspend.hpp(31) : warning C4520: 'boost::chrono::scoped_suspend<Clock>' : multiple default constructors specified
+] [XXXX] [Open]]
[[#] [XXXX] [XXXX] [Close]]
]
+
+
[endsect]
[/=====================================]
@@ -5032,28 +5200,9 @@
[heading Tasks to do before review]
+* Complete documentation
* Fully implement error handling, with test cases.
-* Consider issues raised by Michael Marcin:
-
- In the past I've seen QueryPerformanceCounter give incorrect results,
- especially with SpeedStep processors on laptops. This was many years ago and
- might have been fixed by service packs and drivers.
-
- Typically you check the results of QPC against GetTickCount to see if the
- results are reasonable.
- http://support.microsoft.com/kb/274323
-
- I've also heard of problems with QueryPerformanceCounter in multi-processor
- systems.
-
- I know some people SetThreadAffinityMask to 1 for the current thread call
- their QueryPerformance* functions then restore SetThreadAffinityMask. This
- seems horrible to me because it forces your program to jump to another
- physical processor if it isn't already on cpu0 but they claim it worked well
- in practice because they called the timing functions infrequently.
-
- In the past I have chosen to use timeGetTime with timeBeginPeriod(1) for
- high resolution timers to avoid these issues.
+* Fix open isues.
[heading For later releases]
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -29,8 +29,8 @@
<div class="toc"><dl>
<dt><span class="section"> Appendix A: History</span></dt>
<dd><dl>
-<dt><span class="section"><a href="appendices/history.html#boost_chrono.appendices.history.__version_0_3_2__january_24__2010____new_suspendibleclock___bug_fixes_"><span class="bold"><strong>Version 0.3.2, January 24, 2010</strong></span> <span class="emphasis"><em>New SuspendibleClock
- + Bug fixes</em></span></a></span></dt>
+<dt><span class="section"><a href="appendices/history.html#boost_chrono.appendices.history.__version_0_4__january_24__2010____new_suspendibleclock__new_frequency__lifetime_and_percentage_stopwatch_accumulator__features_"><span class="bold"><strong>Version 0.4, January 24, 2010</strong></span> <span class="emphasis"><em>New SuspendibleClock,
+ New frequency, lifetime and percentage stopwatch_accumulator features</em></span></a></span></dt>
<dt><span class="section"><a href="appendices/history.html#boost_chrono.appendices.history.__version_0_3_1__january_20__2010____new_allow_wide_characters___bug_fixes_"><span class="bold"><strong>Version 0.3.1, January 20, 2010</strong></span> <span class="emphasis"><em>New Allow
wide characters + Bug fixes</em></span></a></span></dt>
<dt><span class="section"><a href="appendices/history.html#boost_chrono.appendices.history.__version_0_3_0__january_17__2010____new_stopwatch_stopclock_feature___bug_fixes_"><span class="bold"><strong>Version 0.3.0, January 17, 2010</strong></span> <span class="emphasis"><em>New stopwatch/stopclock
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/faq.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/faq.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/faq.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -29,7 +29,7 @@
<a name="boost_chrono.appendices.faq"></a> Appendix D: FAQ
</h3></div></div></div>
<a name="boost_chrono.appendices.faq.how_important_is_the_order_of_the_common_type_lt__gt__template_arguments_"></a><h4>
-<a name="id4917271"></a>
+<a name="id4922665"></a>
<a href="faq.html#boost_chrono.appendices.faq.how_important_is_the_order_of_the_common_type_lt__gt__template_arguments_">How
important is the order of the common_type<> template arguments?</a>
</h4>
@@ -60,7 +60,7 @@
is also undefined.
</p>
<a name="boost_chrono.appendices.faq.why_does_stopwatch_reporter_only_display_millisecond_place_precision_when_the_underlying_timer_has_nanosecond_precision_"></a><h4>
-<a name="id4917681"></a>
+<a name="id4923075"></a>
<a href="faq.html#boost_chrono.appendices.faq.why_does_stopwatch_reporter_only_display_millisecond_place_precision_when_the_underlying_timer_has_nanosecond_precision_">Why
does stopwatch_reporter only display millisecond place precision when the
underlying timer has nanosecond precision?</a>
@@ -71,7 +71,7 @@
dangerously.
</p>
<a name="boost_chrono.appendices.faq.why_does_stopwatch_reporter_sometimes_report_more_cpu_seconds_than_real_seconds_"></a><h4>
-<a name="id4917722"></a>
+<a name="id4923116"></a>
<a href="faq.html#boost_chrono.appendices.faq.why_does_stopwatch_reporter_sometimes_report_more_cpu_seconds_than_real_seconds_">Why
does stopwatch_reporter sometimes report more cpu seconds than real seconds?</a>
</h4>
@@ -80,6 +80,14 @@
a debugger, and both for Windows and Linux, that's what the OS appears to
be reporting at times.
</p>
+<a name="boost_chrono.appendices.faq.can_i_obtain_statistics_of_the_time_elapsed_between_calls_to_a_function_"></a><h4>
+<a name="id4923150"></a>
+ <a href="faq.html#boost_chrono.appendices.faq.can_i_obtain_statistics_of_the_time_elapsed_between_calls_to_a_function_">Can
+ I obtain statistics of the time elapsed between calls to a function?</a>
+ </h4>
+<p>
+ The library do not provides this feature.
+ </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/history.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/history.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/history.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -27,8 +27,8 @@
<a name="boost_chrono.appendices.history"></a> Appendix A: History
</h3></div></div></div>
<div class="toc"><dl>
-<dt><span class="section"><a href="history.html#boost_chrono.appendices.history.__version_0_3_2__january_24__2010____new_suspendibleclock___bug_fixes_"><span class="bold"><strong>Version 0.3.2, January 24, 2010</strong></span> <span class="emphasis"><em>New SuspendibleClock
- + Bug fixes</em></span></a></span></dt>
+<dt><span class="section"><a href="history.html#boost_chrono.appendices.history.__version_0_4__january_24__2010____new_suspendibleclock__new_frequency__lifetime_and_percentage_stopwatch_accumulator__features_"><span class="bold"><strong>Version 0.4, January 24, 2010</strong></span> <span class="emphasis"><em>New SuspendibleClock,
+ New frequency, lifetime and percentage stopwatch_accumulator features</em></span></a></span></dt>
<dt><span class="section"><a href="history.html#boost_chrono.appendices.history.__version_0_3_1__january_20__2010____new_allow_wide_characters___bug_fixes_"><span class="bold"><strong>Version 0.3.1, January 20, 2010</strong></span> <span class="emphasis"><em>New Allow
wide characters + Bug fixes</em></span></a></span></dt>
<dt><span class="section"><a href="history.html#boost_chrono.appendices.history.__version_0_3_0__january_17__2010____new_stopwatch_stopclock_feature___bug_fixes_"><span class="bold"><strong>Version 0.3.0, January 17, 2010</strong></span> <span class="emphasis"><em>New stopwatch/stopclock
@@ -41,9 +41,9 @@
</dl></div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_chrono.appendices.history.__version_0_3_2__january_24__2010____new_suspendibleclock___bug_fixes_"></a><a href="history.html#boost_chrono.appendices.history.__version_0_3_2__january_24__2010____new_suspendibleclock___bug_fixes_" title="Version 0.3.2, January 24, 2010 New SuspendibleClock
- + Bug fixes"><span class="bold"><strong>Version 0.3.2, January 24, 2010</strong></span> <span class="emphasis"><em>New SuspendibleClock
- + Bug fixes</em></span></a>
+<a name="boost_chrono.appendices.history.__version_0_4__january_24__2010____new_suspendibleclock__new_frequency__lifetime_and_percentage_stopwatch_accumulator__features_"></a><a href="history.html#boost_chrono.appendices.history.__version_0_4__january_24__2010____new_suspendibleclock__new_frequency__lifetime_and_percentage_stopwatch_accumulator__features_" title="Version 0.4, January 24, 2010 New SuspendibleClock,
+ New frequency, lifetime and percentage stopwatch_accumulator features"><span class="bold"><strong>Version 0.4, January 24, 2010</strong></span> <span class="emphasis"><em>New SuspendibleClock,
+ New frequency, lifetime and percentage stopwatch_accumulator features</em></span></a>
</h4></div></div></div>
<p>
<span class="bold"><strong>Features:</strong></span>
@@ -54,18 +54,17 @@
</li>
<li>
Added scope_suspend which will do nothing if the Clock is not a Suspendible
- Clock concept, and suspend/resume otherwise.
+ Clock concept, and suspend<span class="emphasis"><em>resume otherwise. * Use of scope_suspend
+ while reporting on stopwatch reporter * Added overloading for operator</em></span>(Integer/Duration)
</li>
<li>
- Use of scope_suspend while reporting on stopwatch reporter
+ Added frequency, lifetime and percentage to the default stopwatch_accumulator_formatter
</li>
</ul></div>
<p>
- <span class="bold"><strong>Bug Fixes</strong></span>
+ <span class="bold"><strong>Bug Fixes</strong></span> * Specific formatters doesn't
+ works
</p>
-<div class="itemizedlist"><ul type="disc"><li>
- add static assertions to stopclock and stopclock_accumulator
- </li></ul></div>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/rationale.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/rationale.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/rationale.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -33,7 +33,7 @@
are an extract from this document.
</p>
<a name="boost_chrono.appendices.rationale.is_it_possible_for_the_user_to_pass_a__code__phrase_role__identifier__duration__phrase___code__to_a_function_with_the_units_being_ambiguous_"></a><h4>
-<a name="id4916055"></a>
+<a name="id4921449"></a>
<a href="rationale.html#boost_chrono.appendices.rationale.is_it_possible_for_the_user_to_pass_a__code__phrase_role__identifier__duration__phrase___code__to_a_function_with_the_units_being_ambiguous_">Is
it possible for the user to pass a <code class="computeroutput"><span class="identifier">duration</span></code>
to a function with the units being ambiguous?</a>
@@ -45,7 +45,7 @@
<pre class="programlisting"><span class="identifier">f</span><span class="special">(</span><span class="number">3</span><span class="special">);</span> <span class="comment">// Will not compile, 3 is not implicitly convertible to any `duration`
</span></pre>
<a name="boost_chrono.appendices.rationale.why_duration_needs_operator_"></a><h4>
-<a name="id4916144"></a>
+<a name="id4921539"></a>
<a href="rationale.html#boost_chrono.appendices.rationale.why_duration_needs_operator_">Why
duration needs operator%</a>
</h4>
@@ -73,7 +73,7 @@
<span class="special">};</span>
</pre>
<a name="boost_chrono.appendices.rationale.why_ratio_needs_copyconstruction_and_assignment_from_ratios_having_the_same_normalized_form"></a><h4>
-<a name="id4916725"></a>
+<a name="id4922119"></a>
<a href="rationale.html#boost_chrono.appendices.rationale.why_ratio_needs_copyconstruction_and_assignment_from_ratios_having_the_same_normalized_form">Why
ratio needs CopyConstruction and Assignment from ratios having the same normalized
form</a>
@@ -101,7 +101,7 @@
ratio<1,3> and the compilation succeeds.
</p>
<a name="boost_chrono.appendices.rationale.why_ratio_needs_the_nested_normalizer_typedef_type"></a><h4>
-<a name="id4917038"></a>
+<a name="id4922432"></a>
<a href="rationale.html#boost_chrono.appendices.rationale.why_ratio_needs_the_nested_normalizer_typedef_type">Why
ratio needs the nested normalizer typedef type</a>
</h4>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/tickets.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/tickets.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/tickets.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -59,6 +59,51 @@
<tr>
<td>
<p>
+ 0
+ </p>
+ </td>
+<td>
+ <p>
+ Issues raised by Michael Marcin: In the past I've seen QueryPerformanceCounter
+ give incorrect results, especially with SpeedStep processors on laptops.
+ This was many years ago and might have been fixed by service packs
+ and drivers.
+ </p>
+ <p>
+ Typically you check the results of QPC against GetTickCount to see
+ if the results are reasonable. http://support.microsoft.com/kb/274323
+ </p>
+ <p>
+ I've also heard of problems with QueryPerformanceCounter in multi-processor
+ systems.
+ </p>
+ <p>
+ I know some people SetThreadAffinityMask to 1 for the current thread
+ call their QueryPerformance* functions then restore SetThreadAffinityMask.
+ This seems horrible to me because it forces your program to jump
+ to another physical processor if it isn't already on cpu0 but they
+ claim it worked well in practice because they called the timing functions
+ infrequently.
+ </p>
+ <p>
+ In the past I have chosen to use timeGetTime with timeBeginPeriod(1)
+ for high resolution timers to avoid these issues.
+ </p>
+ </td>
+<td>
+ <p>
+ XXXX
+ </p>
+ </td>
+<td>
+ <p>
+ Open
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
1
</p>
</td>
@@ -492,12 +537,12 @@
<tr>
<td>
<p>
- #
+ 20
</p>
</td>
<td>
<p>
- XXXX
+ Use of Specific formatters doesn't works
</p>
</td>
<td>
@@ -514,12 +559,13 @@
<tr>
<td>
<p>
- #
+ 21
</p>
</td>
<td>
<p>
- XXXX
+ boost/chrono/scoped_suspend.hpp(31) : warning C4520: 'boost::chrono::scoped_suspend<Clock>'
+ : multiple default constructors specified
</p>
</td>
<td>
@@ -529,7 +575,7 @@
</td>
<td>
<p>
- Close
+ Open
</p>
</td>
</tr>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/todo.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/todo.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/appendices/todo.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -26,40 +26,23 @@
<a name="boost_chrono.appendices.todo"></a> Appendix H: Future plans
</h3></div></div></div>
<a name="boost_chrono.appendices.todo.tasks_to_do_before_review"></a><h4>
-<a name="id4920251"></a>
+<a name="id4925742"></a>
<a href="todo.html#boost_chrono.appendices.todo.tasks_to_do_before_review">Tasks
to do before review</a>
</h4>
<div class="itemizedlist"><ul type="disc">
<li>
+ Complete documentation
+ </li>
+<li>
Fully implement error handling, with test cases.
</li>
<li>
- Consider issues raised by Michael Marcin:
+ Fix open isues.
</li>
</ul></div>
-<pre class="programlisting"><span class="identifier">In</span> <span class="identifier">the</span> <span class="identifier">past</span> <span class="identifier">I</span><span class="char">'ve seen QueryPerformanceCounter give incorrect results,
-especially with SpeedStep processors on laptops. This was many years ago and
-might have been fixed by service packs and drivers.
-
-Typically you check the results of QPC against GetTickCount to see if the
-results are reasonable.
-http://support.microsoft.com/kb/274323
-
-I'</span><span class="identifier">ve</span> <span class="identifier">also</span> <span class="identifier">heard</span> <span class="identifier">of</span> <span class="identifier">problems</span> <span class="identifier">with</span> <span class="identifier">QueryPerformanceCounter</span> <span class="identifier">in</span> <span class="identifier">multi</span><span class="special">-</span><span class="identifier">processor</span>
-<span class="identifier">systems</span><span class="special">.</span>
-
-<span class="identifier">I</span> <span class="identifier">know</span> <span class="identifier">some</span> <span class="identifier">people</span> <span class="identifier">SetThreadAffinityMask</span> <span class="identifier">to</span> <span class="number">1</span> <span class="keyword">for</span> <span class="identifier">the</span> <span class="identifier">current</span> <span class="identifier">thread</span> <span class="identifier">call</span>
-<span class="identifier">their</span> <span class="identifier">QueryPerformance</span><span class="special">*</span> <span class="identifier">functions</span> <span class="identifier">then</span> <span class="identifier">restore</span> <span class="identifier">SetThreadAffinityMask</span><span class="special">.</span> <span class="identifier">This</span>
-<span class="identifier">seems</span> <span class="identifier">horrible</span> <span class="identifier">to</span> <span class="identifier">me</span> <span class="identifier">because</span> <span class="identifier">it</span> <span class="identifier">forces</span> <span class="identifier">your</span> <span class="identifier">program</span> <span class="identifier">to</span> <span class="identifier">jump</span> <span class="identifier">to</span> <span class="identifier">another</span>
-<span class="identifier">physical</span> <span class="identifier">processor</span> <span class="keyword">if</span> <span class="identifier">it</span> <span class="identifier">isn</span><span class="error">'</span><span class="identifier">t</span> <span class="identifier">already</span> <span class="identifier">on</span> <span class="identifier">cpu0</span> <span class="identifier">but</span> <span class="identifier">they</span> <span class="identifier">claim</span> <span class="identifier">it</span> <span class="identifier">worked</span> <span class="identifier">well</span>
-<span class="identifier">in</span> <span class="identifier">practice</span> <span class="identifier">because</span> <span class="identifier">they</span> <span class="identifier">called</span> <span class="identifier">the</span> <span class="identifier">timing</span> <span class="identifier">functions</span> <span class="identifier">infrequently</span><span class="special">.</span>
-
-<span class="identifier">In</span> <span class="identifier">the</span> <span class="identifier">past</span> <span class="identifier">I</span> <span class="identifier">have</span> <span class="identifier">chosen</span> <span class="identifier">to</span> <span class="identifier">use</span> <span class="identifier">timeGetTime</span> <span class="identifier">with</span> <span class="identifier">timeBeginPeriod</span><span class="special">(</span><span class="number">1</span><span class="special">)</span> <span class="keyword">for</span>
-<span class="identifier">high</span> <span class="identifier">resolution</span> <span class="identifier">timers</span> <span class="identifier">to</span> <span class="identifier">avoid</span> <span class="identifier">these</span> <span class="identifier">issues</span><span class="special">.</span>
-</pre>
<a name="boost_chrono.appendices.todo.for_later_releases"></a><h4>
-<a name="id4920855"></a>
+<a name="id4925781"></a>
<a href="todo.html#boost_chrono.appendices.todo.for_later_releases">For later
releases</a>
</h4>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/overview/motivation.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/overview/motivation.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/overview/motivation.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -733,7 +733,7 @@
<p>
Will produce the following output
</p>
-<pre class="programlisting"><span class="number">3</span> <span class="identifier">times</span><span class="special">,</span> <span class="identifier">sum</span> <span class="number">0.034</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">min</span> <span class="number">0.006</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">max</span> <span class="number">0.017</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">mean</span> <span class="number">0.011</span><span class="identifier">s</span>
+<pre class="programlisting"><span class="number">3</span> <span class="identifier">times</span><span class="special">,</span> <span class="identifier">sum</span><span class="special">=</span><span class="number">0.034</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">min</span><span class="special">=</span><span class="number">0.006</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">max</span><span class="special">=</span><span class="number">0.017</span><span class="identifier">s</span><span class="special">,</span> <span class="identifier">mean</span><span class="special">=</span><span class="number">0.011</span><span class="identifier">s</span>
</pre>
<p>
It is also helpful if such timing information is broken down into real
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/cpp0x.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/cpp0x.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/cpp0x.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -504,6 +504,9 @@
<span class="keyword">typename</span> <span class="identifier">common_type</span><span class="special"><</span><span class="identifier">Rep1</span><span class="special">,</span> <span class="identifier">Rep2</span><span class="special">>::</span><span class="identifier">type</span>
<span class="keyword">operator</span><span class="special">/(</span><span class="keyword">const</span> <span class="identifier">duration</span><span class="special"><</span><span class="identifier">Rep1</span><span class="special">,</span> <span class="identifier">Period1</span><span class="special">>&</span> <span class="identifier">lhs</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">duration</span><span class="special"><</span><span class="identifier">Rep2</span><span class="special">,</span> <span class="identifier">Period2</span><span class="special">>&</span> <span class="identifier">rhs</span><span class="special">);</span>
+ <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Rep1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Rep2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period</span><span class="special">></span>
+ <span class="keyword">double</span> <span class="keyword">operator</span><span class="special">/(</span><span class="keyword">const</span> <span class="identifier">Rep1</span><span class="special">&</span> <span class="identifier">s</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">duration</span><span class="special"><</span><span class="identifier">Rep2</span><span class="special">,</span> <span class="identifier">Period</span><span class="special">>&</span> <span class="identifier">d</span><span class="special">);</span>
+
<span class="comment">// duration comparisons
</span> <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Rep1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Rep2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period2</span><span class="special">></span>
<span class="keyword">bool</span> <span class="keyword">operator</span><span class="special">==(</span><span class="keyword">const</span> <span class="identifier">duration</span><span class="special"><</span><span class="identifier">Rep1</span><span class="special">,</span> <span class="identifier">Period1</span><span class="special">>&</span> <span class="identifier">lhs</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">duration</span><span class="special"><</span><span class="identifier">Rep2</span><span class="special">,</span> <span class="identifier">Period2</span><span class="special">>&</span> <span class="identifier">rhs</span><span class="special">);</span>
@@ -605,7 +608,7 @@
and both of these calls happen before <code class="computeroutput"><span class="identifier">C1</span><span class="special">::</span><span class="identifier">time_point</span><span class="special">::</span><span class="identifier">max</span><span class="special">()</span></code>.
</p>
<div class="table">
-<a name="id4834136"></a><p class="title"><b>Table 1. Clock Requirements</b></p>
+<a name="id4839076"></a><p class="title"><b>Table 1. Clock Requirements</b></p>
<table class="table" summary="Clock Requirements">
<colgroup>
<col>
@@ -1379,6 +1382,8 @@
Non-Member function <code class="computeroutput"><span class="keyword">operator</span><span class="special">/(</span><span class="identifier">duration</span><span class="special">,</span><span class="identifier">Rep2</span><span class="special">)</span></code></a></span></dt>
<dt><span class="section"><a href="cpp0x.html#boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_d_2">
Non-Member function <code class="computeroutput"><span class="keyword">operator</span><span class="special">/(</span><span class="identifier">duration</span><span class="special">,</span><span class="identifier">duration</span><span class="special">)</span></code></a></span></dt>
+<dt><span class="section"><a href="cpp0x.html#boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_d_3">
+ Non-Member function <code class="computeroutput"><span class="keyword">operator</span><span class="special">/(</span><span class="identifier">Rep1</span><span class="special">,</span><span class="identifier">duration</span><span class="special">)</span></code></a></span></dt>
<dt><span class="section"><a href="cpp0x.html#boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_mod_1">
Non-Member function <code class="computeroutput"><span class="keyword">operator</span><span class="special">%(</span><span class="identifier">duration</span><span class="special">,</span><span class="identifier">Rep2</span><span class="special">)</span></code></a></span></dt>
<dt><span class="section"><a href="cpp0x.html#boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_mod_2">
@@ -1495,6 +1500,29 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h6 class="title">
+<a name="boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_d_3"></a><a href="cpp0x.html#boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_d_3" title="
+ Non-Member function operator/(Rep1,duration)">
+ Non-Member function <code class="computeroutput"><span class="keyword">operator</span><span class="special">/(</span><span class="identifier">Rep1</span><span class="special">,</span><span class="identifier">duration</span><span class="special">)</span></code></a>
+</h6></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Rep1</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Rep2</span><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">Period</span><span class="special">></span>
+<span class="keyword">double</span> <span class="keyword">operator</span><span class="special">/(</span><span class="keyword">const</span> <span class="identifier">Rep1</span><span class="special">&</span> <span class="identifier">s</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">duration</span><span class="special"><</span><span class="identifier">Rep2</span><span class="special">,</span> <span class="identifier">Period</span><span class="special">>&</span> <span class="identifier">d</span><span class="special">);</span>
+</pre>
+<p>
+ <span class="bold"><strong>Remarks:</strong></span> Let <code class="computeroutput"><span class="identifier">CR</span></code>
+ represent the <code class="computeroutput"><span class="identifier">common_type</span></code>
+ of <code class="computeroutput"><span class="identifier">Rep1</span></code> and <code class="computeroutput"><span class="identifier">Rep2</span></code>. This function will not participate
+ in overload resolution unless both <code class="computeroutput"><span class="identifier">Rep1</span></code>
+ and <code class="computeroutput"><span class="identifier">Rep2</span></code> are implicitly
+ convertible to <code class="computeroutput"><span class="identifier">CR</span></code>,
+ and <code class="computeroutput"><span class="identifier">Rep1</span></code> is not an
+ instantiation of <code class="computeroutput"><span class="identifier">duration</span></code>.
+ </p>
+<p>
+ <span class="bold"><strong>Returns:</strong></span> <code class="computeroutput"><span class="identifier">CR</span><span class="special">(</span><span class="identifier">s</span><span class="special">)/</span><span class="identifier">duration</span><span class="special"><</span><span class="identifier">CR</span><span class="special">,</span> <span class="identifier">Period</span><span class="special">>(</span><span class="identifier">d</span><span class="special">)</span></code>.
+ </p>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h6 class="title">
<a name="boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_mod_1"></a><a href="cpp0x.html#boost_chrono.reference.cpp0x.chrono_chrono_hpp.duration_non_member_arithmetic.duration_operator_mod_1" title="
Non-Member function operator%(duration,Rep2)">
Non-Member function <code class="computeroutput"><span class="keyword">operator</span><span class="special">%(</span><span class="identifier">duration</span><span class="special">,</span><span class="identifier">Rep2</span><span class="special">)</span></code></a>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/other_clocks.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/other_clocks.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/other_clocks.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -304,7 +304,7 @@
<code class="computeroutput"><span class="identifier">clock</span></code> types.
</p>
<div class="table">
-<a name="id4856674"></a><p class="title"><b>Table 2. SuspendibleClock Requirements</b></p>
+<a name="id4861995"></a><p class="title"><b>Table 2. SuspendibleClock Requirements</b></p>
<table class="table" summary="SuspendibleClock Requirements">
<colgroup>
<col>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_formatters.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_formatters.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_formatters.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -167,7 +167,8 @@
</p>
<p>
The default format is "%c times, sum<code class="literal">%ss, min</code>%ms,
- max<code class="literal">%Ms, mean</code>%as\n", where
+ max<code class="literal">%Ms, mean</code>%as, frequency<code class="literal">%fherzs, lifetime</code>%ls,
+ percentage=%p%\n", where
</p>
<div class="itemizedlist"><ul type="disc">
<li>
@@ -190,10 +191,23 @@
<code class="computeroutput"><span class="special">%</span><span class="identifier">a</span></code>
: the mean of the samples of elapsed time between the call to start/stop.
</li>
+<li>
+<code class="computeroutput"><span class="special">%</span><span class="identifier">f</span></code>
+ : the frequency of calls to start.
+ </li>
+<li>
+<code class="computeroutput"><span class="special">%</span><span class="identifier">l</span></code>
+ : the lifetime of the stopwatch_accumulator.
+ </li>
+<li>
+<code class="computeroutput"><span class="special">%</span><span class="identifier">p</span></code>
+ : the percentage of time spent by this stopwatch respect to its lifetime.
+ </li>
</ul></div>
<p>
- The time is given using the suffix "s" following the System
- International d'Unites Std.
+ The time is given using the suffix "s", the frequency is given
+ using the suffix "herzs", both following the System International
+ d'Unites Std.
</p>
</div>
</div>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_reporters.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_reporters.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatch_reporters.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -78,7 +78,7 @@
<code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span></code>, ec is a system::error_code
</p>
<div class="table">
-<a name="id4868453"></a><p class="title"><b>Table 4. Stopwatch Requirements</b></p>
+<a name="id4873774"></a><p class="title"><b>Table 4. Stopwatch Requirements</b></p>
<table class="table" summary="Stopwatch Requirements">
<colgroup>
<col>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatches.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatches.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/reference/stopwatches.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -135,7 +135,7 @@
is an instance of <code class="computeroutput"><span class="identifier">S</span></code>.
</p>
<div class="table">
-<a name="id4860199"></a><p class="title"><b>Table 3. Stopwatch Requirements</b></p>
+<a name="id4865520"></a><p class="title"><b>Table 3. Stopwatch Requirements</b></p>
<table class="table" summary="Stopwatch Requirements">
<colgroup>
<col>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -36,8 +36,6 @@
</dl></dd>
<dt><span class="section">Tutorial</span></dt>
<dd><dl>
-<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.thread_clock">thread
- clock</a></span></dt>
<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_to_define_a_thread_clock">How
to define a thread clock</a></span></dt>
<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_prefix_each_report_with__boost_current_function__function_signature_">How
@@ -49,10 +47,10 @@
I use an stopclock accumulator which is not static?</a></span></dt>
<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_suspend_a_stopwatch_">How
can I suspend a stopwatch?</a></span></dt>
-<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_get_specific_statistics_from_stopwatches_accumulator">How
- get specific statistics from stopwatches accumulator</a></span></dt>
-<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_defaul_do_not_satisfy_my_expectations">How
- can I make a specific formatter when the defaul do not satisfy my expectations</a></span></dt>
+<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_to_get_specific_statistics_from_stopwatches_accumulator_">How
+ to get specific statistics from stopwatches accumulator?</a></span></dt>
+<dt><span class="section"><a href="users_guide/tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_default_do_not_satisfy_my_expectations">How
+ can I make a specific formatter when the default do not satisfy my expectations</a></span></dt>
</dl></dd>
<dt><span class="section"> References</span></dt>
</dl></div>
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/getting_started.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/getting_started.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/getting_started.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -39,7 +39,7 @@
Installing Chrono</a>
</h4></div></div></div>
<a name="boost_chrono.users_guide.getting_started.install.getting__emphasis_role__bold__boost_chrono__emphasis__"></a><h5>
-<a name="id4817366"></a>
+<a name="id4817378"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.getting__emphasis_role__bold__boost_chrono__emphasis__">Getting
<span class="bold"><strong>Boost.Chrono</strong></span> </a>
</h5>
@@ -53,7 +53,7 @@
Sandbox</a>.
</p>
<a name="boost_chrono.users_guide.getting_started.install.where_to_install__emphasis_role__bold__boost_chrono__emphasis___"></a><h5>
-<a name="id4817426"></a>
+<a name="id4817439"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.where_to_install__emphasis_role__bold__boost_chrono__emphasis___">Where
to install <span class="bold"><strong>Boost.Chrono</strong></span>? </a>
</h5>
@@ -69,7 +69,7 @@
variable. Any help is welcome.
</p>
<a name="boost_chrono.users_guide.getting_started.install.building__emphasis_role__bold__boost_chrono__emphasis__"></a><h5>
-<a name="id4817469"></a>
+<a name="id4817481"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.building__emphasis_role__bold__boost_chrono__emphasis__">Building
<span class="bold"><strong>Boost.Chrono</strong></span> </a>
</h5>
@@ -80,7 +80,7 @@
<pre class="programlisting"><span class="identifier">bjam</span> <span class="identifier">libs</span><span class="special">/</span><span class="identifier">chrono</span><span class="special">/</span><span class="identifier">build</span>
</pre>
<a name="boost_chrono.users_guide.getting_started.install.requirements"></a><h5>
-<a name="id4817537"></a>
+<a name="id4817549"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.requirements">Requirements</a>
</h5>
<p>
@@ -129,7 +129,7 @@
</dl>
</div>
<a name="boost_chrono.users_guide.getting_started.install.building_an_executable_that_uses__emphasis_role__bold__boost_chrono__emphasis__"></a><h5>
-<a name="id4817737"></a>
+<a name="id4817750"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.building_an_executable_that_uses__emphasis_role__bold__boost_chrono__emphasis__">Building
an executable that uses <span class="bold"><strong>Boost.Chrono</strong></span>
</a>
@@ -139,7 +139,7 @@
with the Boost System library.
</p>
<a name="boost_chrono.users_guide.getting_started.install.exceptions_safety_"></a><h5>
-<a name="id4817773"></a>
+<a name="id4817786"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.exceptions_safety_">Exceptions
safety </a>
</h5>
@@ -148,7 +148,7 @@
of exception safety as long as the underlying parameters provide it.
</p>
<a name="boost_chrono.users_guide.getting_started.install.thread_safety_"></a><h5>
-<a name="id4817800"></a>
+<a name="id4817812"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.thread_safety_">Thread
safety </a>
</h5>
@@ -156,7 +156,7 @@
All functions in the library are thread-unsafe except when noted explicitly.
</p>
<a name="boost_chrono.users_guide.getting_started.install.tested_compilers_"></a><h5>
-<a name="id4817824"></a>
+<a name="id4817837"></a>
<a href="getting_started.html#boost_chrono.users_guide.getting_started.install.tested_compilers_">Tested
compilers </a>
</h5>
@@ -175,7 +175,7 @@
MSVC 9.0 Express
</li>
<li>
- MSVC 5.0
+ MSVC 8.0
</li>
</ul></div>
<p>
@@ -244,12 +244,12 @@
<p>
Here is a complete program (stopclock_example.cpp):
</p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">chrono</span><span class="special">/</span><span class="identifier">process_times</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">chrono</span><span class="special">/</span><span class="identifier">stopclock</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cmath</span><span class="special">></span>
<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
<span class="special">{</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">stopclockstopclock</span><span class="special"><></span> <span class="identifier">t</span><span class="special">;</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">stopclock</span><span class="special"><></span> <span class="identifier">t</span><span class="special">;</span>
<span class="keyword">for</span> <span class="special">(</span> <span class="keyword">long</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="number">10000000</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">sqrt</span><span class="special">(</span> <span class="number">123.456L</span> <span class="special">);</span> <span class="comment">// burn some time
Modified: sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/tutorial.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/tutorial.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/boost_chrono/users_guide/tutorial.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -27,8 +27,6 @@
<a name="boost_chrono.users_guide.tutorial"></a>Tutorial
</h3></div></div></div>
<div class="toc"><dl>
-<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.thread_clock">thread
- clock</a></span></dt>
<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_to_define_a_thread_clock">How
to define a thread clock</a></span></dt>
<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_prefix_each_report_with__boost_current_function__function_signature_">How
@@ -40,38 +38,190 @@
I use an stopclock accumulator which is not static?</a></span></dt>
<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_suspend_a_stopwatch_">How
can I suspend a stopwatch?</a></span></dt>
-<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_get_specific_statistics_from_stopwatches_accumulator">How
- get specific statistics from stopwatches accumulator</a></span></dt>
-<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_defaul_do_not_satisfy_my_expectations">How
- can I make a specific formatter when the defaul do not satisfy my expectations</a></span></dt>
+<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_to_get_specific_statistics_from_stopwatches_accumulator_">How
+ to get specific statistics from stopwatches accumulator?</a></span></dt>
+<dt><span class="section"><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_default_do_not_satisfy_my_expectations">How
+ can I make a specific formatter when the default do not satisfy my expectations</a></span></dt>
</dl></div>
-<div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title">
-<a name="boost_chrono.users_guide.tutorial.thread_clock"></a><a href="tutorial.html#boost_chrono.users_guide.tutorial.thread_clock" title="thread
- clock">thread
- clock</a>
-</h4></div></div></div></div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_chrono.users_guide.tutorial.how_to_define_a_thread_clock"></a><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_to_define_a_thread_clock" title="How
to define a thread clock">How
to define a thread clock</a>
</h4></div></div></div>
+<p>
+ On posix systems for which the macro _POSIX_THREAD_CPUTIME is defined we
+ can get the time associated to a specific thread.
+ </p>
<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">thread_clock</span> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
- <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">intmax_t</span> <span class="identifier">rep</span><span class="special">;</span>
- <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">nanoseconds</span> <span class="identifier">period</span><span class="special">;</span>
- <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special"><</span><span class="identifier">rep</span><span class="special">,</span> <span class="identifier">period</span><span class="special">></span> <span class="identifier">duration</span><span class="special">;</span>
- <span class="keyword">typedef</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">time_point</span><span class="special"><</span><span class="identifier">Clock</span><span class="special">></span> <span class="identifier">time_point</span><span class="special">;</span>
- <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_monotonic</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
-
- <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">()</span> <span class="special">{</span>
- <span class="comment">// get the current thread
-</span> <span class="comment">// get the clock_id associated to the current thread
-</span> <span class="comment">// get the clock_t associated to the thread clock
-</span> <span class="comment">// transform to nanoseconds
-</span> <span class="special">}</span>
+ <span class="keyword">typedef</span> <span class="identifier">nanoseconds</span> <span class="identifier">duration</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">duration</span><span class="special">::</span><span class="identifier">rep</span> <span class="identifier">rep</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">duration</span><span class="special">::</span><span class="identifier">period</span> <span class="identifier">period</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">chrono</span><span class="special">::</span><span class="identifier">time_point</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">></span> <span class="identifier">time_point</span><span class="special">;</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">is_monotonic</span> <span class="special">=</span> <span class="keyword">true</span><span class="special">;</span>
+
+ <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">(</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// get the current thread
+</span> <span class="identifier">pthread_t</span> <span class="identifier">pth</span><span class="special">=</span><span class="identifier">pthread_self</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span>
+ <span class="comment">// get the clock_id associated to the current thread
+</span> <span class="identifier">clockid_t</span> <span class="identifier">clock_id</span><span class="special">;</span>
+ <span class="identifier">pthread_getcpuclockid</span><span class="special">(</span><span class="identifier">pth</span><span class="special">,</span> <span class="identifier">clock_id</span><span class="special">);</span>
+ <span class="comment">// get the timespec associated to the thread clock
+</span> <span class="keyword">struct</span> <span class="identifier">timespec</span> <span class="identifier">ts</span><span class="special">;</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">::</span><span class="identifier">clock_gettime</span><span class="special">(</span> <span class="identifier">clock_id</span><span class="special">,</span> <span class="special">&</span><span class="identifier">ts</span> <span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">throw_exception</span><span class="special">(</span>
+ <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_error</span><span class="special">(</span> <span class="identifier">errno</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_category</span><span class="special">,</span> <span class="string">"chrono::thread_clock"</span> <span class="special">));</span>
+ <span class="special">}</span>
+
+ <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
+ <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">(</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="special">&</span> <span class="identifier">ec</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// get the current thread
+</span> <span class="identifier">pthread_t</span> <span class="identifier">pth</span><span class="special">=</span><span class="identifier">pthread_self</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span>
+ <span class="comment">// get the clock_id associated to the current thread
+</span> <span class="identifier">clockid_t</span> <span class="identifier">clock_id</span><span class="special">;</span>
+ <span class="identifier">pthread_getcpuclockid</span><span class="special">(</span><span class="identifier">pth</span><span class="special">,</span> <span class="identifier">clock_id</span><span class="special">);</span>
+ <span class="comment">// get the timespec associated to the thread clock
+</span> <span class="keyword">struct</span> <span class="identifier">timespec</span> <span class="identifier">ts</span><span class="special">;</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">::</span><span class="identifier">clock_gettime</span><span class="special">(</span> <span class="identifier">clock_id</span><span class="special">,</span> <span class="special">&</span><span class="identifier">ts</span> <span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span> <span class="identifier">errno</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_category</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span>
+ <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ class thread_clock { public: typedef nanoseconds duration; typedef duration::rep
+ rep; typedef duration::period period; typedef chrono::time_point<process_real_cpu_clock>
+ time_point; static const bool is_monotonic = true;
+ </p>
+<pre class="programlisting"> <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">(</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// get the current thread
+</span> <span class="identifier">pthread_t</span> <span class="identifier">pth</span><span class="special">=</span><span class="identifier">pthread_self</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span>
+ <span class="comment">// get the clock_id associated to the current thread
+</span> <span class="identifier">clockid_t</span> <span class="identifier">clock_id</span><span class="special">;</span>
+ <span class="identifier">pthread_getcpuclockid</span><span class="special">(</span><span class="identifier">pth</span><span class="special">,</span> <span class="identifier">clock_id</span><span class="special">);</span>
+ <span class="comment">// get the timespec associated to the thread clock
+</span> <span class="keyword">struct</span> <span class="identifier">timespec</span> <span class="identifier">ts</span><span class="special">;</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">::</span><span class="identifier">clock_gettime</span><span class="special">(</span> <span class="identifier">clock_id</span><span class="special">,</span> <span class="special">&</span><span class="identifier">ts</span> <span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">throw_exception</span><span class="special">(</span>
+ <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_error</span><span class="special">(</span> <span class="identifier">errno</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_category</span><span class="special">,</span> <span class="string">"chrono::thread_clock"</span> <span class="special">));</span>
+ <span class="special">}</span>
+
+ <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
+ <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">(</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="special">&</span> <span class="identifier">ec</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// get the current thread
+</span> <span class="identifier">pthread_t</span> <span class="identifier">pth</span><span class="special">=</span><span class="identifier">pthread_self</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span>
+ <span class="comment">// get the clock_id associated to the current thread
+</span> <span class="identifier">clockid_t</span> <span class="identifier">clock_id</span><span class="special">;</span>
+ <span class="identifier">pthread_getcpuclockid</span><span class="special">(</span><span class="identifier">pth</span><span class="special">,</span> <span class="identifier">clock_id</span><span class="special">);</span>
+ <span class="comment">// get the timespec associated to the thread clock
+</span> <span class="keyword">struct</span> <span class="identifier">timespec</span> <span class="identifier">ts</span><span class="special">;</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">::</span><span class="identifier">clock_gettime</span><span class="special">(</span> <span class="identifier">clock_id</span><span class="special">,</span> <span class="special">&</span><span class="identifier">ts</span> <span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span> <span class="identifier">errno</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_category</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span>
+ <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ static time_point now( ) { <span class="emphasis"><em>/ get the current thread pthread_t
+ pth=pthread_self(void); /</em></span> get the clock_id associated to the
+ current thread clockid_t clock_id; pthread_getcpuclockid(pth, clock_id);
+ // get the timespec associated to the thread clock struct timespec ts;
+ if ( ::clock_gettime( clock_id, &ts ) ) { boost::throw_exception( system::system_error(
+ errno, system::system_category, "chrono::thread_clock" )); }
+ </p>
+<pre class="programlisting"> <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
+ <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">(</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="special">&</span> <span class="identifier">ec</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// get the current thread
+</span> <span class="identifier">pthread_t</span> <span class="identifier">pth</span><span class="special">=</span><span class="identifier">pthread_self</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span>
+ <span class="comment">// get the clock_id associated to the current thread
+</span> <span class="identifier">clockid_t</span> <span class="identifier">clock_id</span><span class="special">;</span>
+ <span class="identifier">pthread_getcpuclockid</span><span class="special">(</span><span class="identifier">pth</span><span class="special">,</span> <span class="identifier">clock_id</span><span class="special">);</span>
+ <span class="comment">// get the timespec associated to the thread clock
+</span> <span class="keyword">struct</span> <span class="identifier">timespec</span> <span class="identifier">ts</span><span class="special">;</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">::</span><span class="identifier">clock_gettime</span><span class="special">(</span> <span class="identifier">clock_id</span><span class="special">,</span> <span class="special">&</span><span class="identifier">ts</span> <span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span> <span class="identifier">errno</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_category</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span>
+ <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
<span class="special">};</span>
</pre>
+<p>
+ // transform to nanoseconds return time_point(duration( static_cast<thread_clock::rep>(
+ ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+ </p>
+<pre class="programlisting"> <span class="special">}</span>
+ <span class="keyword">static</span> <span class="identifier">time_point</span> <span class="identifier">now</span><span class="special">(</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="special">&</span> <span class="identifier">ec</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="comment">// get the current thread
+</span> <span class="identifier">pthread_t</span> <span class="identifier">pth</span><span class="special">=</span><span class="identifier">pthread_self</span><span class="special">(</span><span class="keyword">void</span><span class="special">);</span>
+ <span class="comment">// get the clock_id associated to the current thread
+</span> <span class="identifier">clockid_t</span> <span class="identifier">clock_id</span><span class="special">;</span>
+ <span class="identifier">pthread_getcpuclockid</span><span class="special">(</span><span class="identifier">pth</span><span class="special">,</span> <span class="identifier">clock_id</span><span class="special">);</span>
+ <span class="comment">// get the timespec associated to the thread clock
+</span> <span class="keyword">struct</span> <span class="identifier">timespec</span> <span class="identifier">ts</span><span class="special">;</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">::</span><span class="identifier">clock_gettime</span><span class="special">(</span> <span class="identifier">clock_id</span><span class="special">,</span> <span class="special">&</span><span class="identifier">ts</span> <span class="special">)</span> <span class="special">)</span>
+ <span class="special">{</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">assign</span><span class="special">(</span> <span class="identifier">errno</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">system_category</span> <span class="special">);</span>
+ <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">();</span>
+ <span class="special">}</span>
+ <span class="identifier">ec</span><span class="special">.</span><span class="identifier">clear</span><span class="special">();</span>
+ <span class="comment">// transform to nanoseconds
+</span> <span class="keyword">return</span> <span class="identifier">time_point</span><span class="special">(</span><span class="identifier">duration</span><span class="special">(</span>
+ <span class="keyword">static_cast</span><span class="special"><</span><span class="identifier">thread_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">>(</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_sec</span> <span class="special">)</span> <span class="special">*</span> <span class="number">1000000000</span> <span class="special">+</span> <span class="identifier">ts</span><span class="special">.</span><span class="identifier">tv_nsec</span><span class="special">));</span>
+
+ <span class="special">}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ } static time_point now( system::error_code & ec ) { <span class="emphasis"><em>/ get
+ the current thread pthread_t pth=pthread_self(void); /</em></span> get the
+ clock_id associated to the current thread clockid_t clock_id; pthread_getcpuclockid(pth,
+ clock_id); <span class="emphasis"><em>/ get the timespec associated to the thread clock
+ struct timespec ts; if ( ::clock_gettime( clock_id, &ts ) ) { ec.assign(
+ errno, system::system_category ); return time_point(); } ec.clear(); /</em></span>
+ transform to nanoseconds return time_point(duration( static_cast<thread_clock::rep>(
+ ts.tv_sec ) * 1000000000 + ts.tv_nsec));
+ </p>
+<pre class="programlisting"> <span class="special">}</span>
+<span class="special">};</span>
+</pre>
+<p>
+ } };
+ </p>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
@@ -102,7 +252,7 @@
<span class="keyword">static</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">stopclock_accumulator</span><span class="special"><></span> <span class="identifier">BOOST_JOIN</span><span class="special">(</span><span class="identifier">_boost_chrono_stopclock_accumulator_</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">)(</span> <span class="special">\</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span><span class="special">(</span><span class="identifier">BOOST_CURRENT_FUNCTION</span><span class="special">)</span> <span class="special">+</span> <span class="string">": "</span> <span class="special">+</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">stopwatch_accumulator_formatter</span><span class="special">::</span><span class="identifier">default_format</span><span class="special">()</span> <span class="special">\</span>
<span class="special">);</span> <span class="special">\</span>
- <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">stopclock_accumulator</span><span class="special"><>::</span><span class="identifier">scoped_stop</span> <span class="identifier">BOOST_JOIN</span><span class="special">(</span><span class="identifier">_boost_chrono_stopclock_accumulator_run_</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">)(</span><span class="identifier">BOOST_JOIN</span><span class="special">(</span><span class="identifier">_boost_chrono_stopclock_accumulator_</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">))</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">stopclock_accumulator</span><span class="special"><>::</span><span class="identifier">scoped_run</span> <span class="identifier">BOOST_JOIN</span><span class="special">(</span><span class="identifier">_boost_chrono_stopclock_accumulator_run_</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">)(</span><span class="identifier">BOOST_JOIN</span><span class="special">(</span><span class="identifier">_boost_chrono_stopclock_accumulator_</span><span class="special">,</span> <span class="identifier">__LINE__</span><span class="special">))</span>
</pre>
<p>
With this macro you will just ave
@@ -122,7 +272,7 @@
can I prefix each report with <code class="computeroutput"><span class="identifier">__FILE__</span><span class="special">[</span><span class="identifier">__LINE__</span><span class="special">]</span></code> pattern?</a>
</h4></div></div></div>
<p>
- When you want to prefixx with the <code class="computeroutput"><span class="identifier">__FILE__</span><span class="special">[</span><span class="identifier">__LINE__</span><span class="special">]</span></code> pattern you can follow the same technique
+ When you want to prefix with the <code class="computeroutput"><span class="identifier">__FILE__</span><span class="special">[</span><span class="identifier">__LINE__</span><span class="special">]</span></code> pattern you can follow the same technique
as described below:
</p>
<pre class="programlisting"><span class="preprocessor">#define</span> <span class="identifier">REPORT_LINE_ACCUMULATED_LIFETIME</span> <span class="special">\</span>
@@ -192,16 +342,31 @@
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_chrono.users_guide.tutorial.how_get_specific_statistics_from_stopwatches_accumulator"></a><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_get_specific_statistics_from_stopwatches_accumulator" title="How
- get specific statistics from stopwatches accumulator">How
- get specific statistics from stopwatches accumulator</a>
+<a name="boost_chrono.users_guide.tutorial.how_to_get_specific_statistics_from_stopwatches_accumulator_"></a><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_to_get_specific_statistics_from_stopwatches_accumulator_" title="How
+ to get specific statistics from stopwatches accumulator?">How
+ to get specific statistics from stopwatches accumulator?</a>
</h4></div></div></div>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">chrono</span><span class="special">/</span><span class="identifier">stopwatches</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">cmath</span><span class="special">></span>
+<p>
+ There are two use cases that coul need to change the statistics associated
+ to a stopwatches accumulator:
+ </p>
+<div class="orderedlist"><ol type="1">
+<li>
+ We want to reduce the default reporting and we preffer to adapt the statistics
+ to the reporting
+ </li>
+<li>
+ We want to report other statistics of the samples
+ </li>
+</ol></div>
+<p>
+ 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.
+ </p>
+<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span><span class="special">;</span>
-<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">;</span>
-<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">accumulators</span><span class="special">;</span>
-<span class="keyword">typedef</span> <span class="identifier">stopwatch_accumulator</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">,</span> <span class="identifier">kind</span><span class="special">::</span><span class="identifier">running</span><span class="special">,</span>
+<span class="keyword">typedef</span> <span class="identifier">stopwatch_accumulator</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">,</span>
<span class="identifier">accumulator_set</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">,</span>
<span class="identifier">features</span><span class="special"><</span>
<span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span><span class="special">,</span>
@@ -213,7 +378,7 @@
<span class="keyword">int</span> <span class="identifier">f1</span><span class="special">(</span><span class="keyword">long</span> <span class="identifier">j</span><span class="special">)</span>
<span class="special">{</span>
- <span class="keyword">static</span> <span class="identifier">my_stopwatch_accumulator_reporter</span> <span class="identifier">acc</span><span class="special">(</span><span class="identifier">BOOST_CHRONO_ACCUMULATOR_FUNCTION_FORMAT</span><span class="special">);</span>
+ <span class="keyword">static</span> <span class="identifier">my_stopwatch_accumulator_reporter</span> <span class="identifier">acc</span><span class="special">(</span><span class="string">"%c times, sum=%ss, mean=%as\n"</span><span class="special">);</span>
<span class="identifier">my_stopwatch_accumulator_reporter</span><span class="special">::</span><span class="identifier">scoped_run</span> <span class="identifier">_</span><span class="special">(</span><span class="identifier">acc</span><span class="special">);</span>
<span class="keyword">for</span> <span class="special">(</span> <span class="keyword">long</span> <span class="identifier">i</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span> <span class="identifier">i</span> <span class="special"><</span> <span class="identifier">j</span><span class="special">;</span> <span class="special">++</span><span class="identifier">i</span> <span class="special">)</span>
@@ -221,21 +386,116 @@
</span>
<span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
<span class="special">}</span>
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
+</pre>
+<p>
+ But wat would hapend if we haven't forced the format:
+ </p>
+<pre class="programlisting"><span class="keyword">static</span> <span class="identifier">my_stopwatch_accumulator_reporter</span> <span class="identifier">acc</span><span class="special">;</span>
+<span class="identifier">my_stopwatch_accumulator_reporter</span><span class="special">::</span><span class="identifier">scoped_run</span> <span class="identifier">_</span><span class="special">(</span><span class="identifier">acc</span><span class="special">);</span>
+</pre>
+<p>
+ Unfortunately there is no error at compile time. Fortunately, the run-time
+ execution is not undefined and will return 0 for the missing statistics.
+ </p>
+</div>
+<div class="section" lang="en">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_default_do_not_satisfy_my_expectations"></a><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_default_do_not_satisfy_my_expectations" title="How
+ can I make a specific formatter when the default do not satisfy my expectations">How
+ can I make a specific formatter when the default do not satisfy my expectations</a>
+</h4></div></div></div>
+<p>
+ Imagine then that we want to report the tag::variance(lazy). We will need
+ to include the specific accumulator file
+ </p>
+<pre class="programlisting"><span class="special">...</span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">accumulators</span><span class="special">/</span><span class="identifier">statistics</span><span class="special">/</span><span class="identifier">variance</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="special">...</span>
+<span class="keyword">typedef</span> <span class="identifier">stopwatch_accumulator</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">,</span>
+ <span class="identifier">accumulator_set</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">,</span>
+ <span class="identifier">features</span><span class="special"><</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span><span class="special">,</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">,</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">,</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">)</span>
+ <span class="special">></span>
+ <span class="special">></span>
+<span class="special">>::</span><span class="identifier">reporter</span> <span class="identifier">my_stopwatch_accumulator_reporter</span><span class="special">;</span>
+</pre>
+<p>
+ 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 own own accumulator formatter.
+ </p>
+<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">stopwatch_accumulator</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">,</span>
+ <span class="identifier">accumulator_set</span><span class="special"><</span><span class="identifier">process_real_cpu_clock</span><span class="special">::</span><span class="identifier">rep</span><span class="special">,</span>
+ <span class="identifier">features</span><span class="special"><</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">count</span><span class="special">,</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">sum</span><span class="special">,</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">mean</span><span class="special">,</span>
+ <span class="identifier">tag</span><span class="special">::</span><span class="identifier">variance</span><span class="special">(</span><span class="identifier">lazy</span><span class="special">)</span>
+ <span class="special">></span>
+ <span class="special">>,</span>
+ <span class="identifier">my_stopwatch_accumulator_formatter</span>
+<span class="special">>::</span><span class="identifier">reporter</span> <span class="identifier">my_stopwatch_accumulator_reporter</span><span class="special">;</span>
+</pre>
+<p>
+ Next follow the definition of a formatter taking care of count, sum, mean
+ and variance
+ </p>
+<pre class="programlisting"><span class="keyword">class</span> <span class="identifier">my_stopwatch_accumulator_formatter</span> <span class="special">{</span>
+<span class="keyword">public</span><span class="special">:</span>
+ <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">string</span> <span class="identifier">string_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="keyword">char</span> <span class="identifier">char_type</span><span class="special">;</span>
+ <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ostream</span> <span class="identifier">ostream_type</span><span class="special">;</span>
- <span class="identifier">f1</span><span class="special">(</span><span class="number">100000</span><span class="special">);</span>
- <span class="identifier">f1</span><span class="special">(</span><span class="number">200000</span><span class="special">);</span>
- <span class="identifier">f1</span><span class="special">(</span><span class="number">300000</span><span class="special">);</span>
- <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span>
-<span class="special">}</span>
+ <span class="keyword">static</span> <span class="identifier">ostream_type</span> <span class="special">&</span> <span class="identifier">default_os</span><span class="special">()</span> <span class="special">{</span><span class="keyword">return</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span><span class="special">;}</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">char_type</span><span class="special">*</span> <span class="identifier">default_format</span><span class="special">()</span> <span class="special">{</span><span class="keyword">return</span> <span class="string">"%c times, sum=%ss, mean=%as, variance=%vs\n"</span><span class="special">;}</span>
+ <span class="keyword">static</span> <span class="keyword">int</span> <span class="identifier">default_places</span><span class="special">()</span> <span class="special">{</span> <span class="keyword">return</span> <span class="number">3</span><span class="special">;</span> <span class="special">}</span>
+
+ <span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">Stopwatch</span> <span class="special">></span>
+ <span class="keyword">static</span> <span class="keyword">void</span> <span class="identifier">show_time</span><span class="special">(</span> <span class="identifier">Stopwatch</span> <span class="special">&</span> <span class="identifier">stopwatch_</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">char_type</span><span class="special">*</span> <span class="identifier">format</span><span class="special">,</span>
+ <span class="keyword">int</span> <span class="identifier">places</span><span class="special">,</span> <span class="identifier">ostream_type</span> <span class="special">&</span> <span class="identifier">os</span><span class="special">,</span> <span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="special">&</span> <span class="identifier">ec</span><span class="special">)</span>
+ <span class="special">{</span>
+ <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="identifier">Stopwatch</span><span class="special">::</span><span class="identifier">duration</span> <span class="identifier">duration_t</span><span class="special">;</span>
+ <span class="keyword">typename</span> <span class="identifier">Stopwatch</span><span class="special">::</span><span class="identifier">accumulator</span> <span class="identifier">accumulator</span><span class="special">&</span> <span class="identifier">acc</span> <span class="special">=</span> <span class="identifier">stopwatch_</span><span class="special">.</span><span class="identifier">accumulated</span><span class="special">();</span>
+
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">io</span><span class="special">::</span><span class="identifier">ios_flags_saver</span> <span class="identifier">ifs</span><span class="special">(</span> <span class="identifier">os</span> <span class="special">);</span>
+ <span class="identifier">os</span><span class="special">.</span><span class="identifier">setf</span><span class="special">(</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">fixed</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ios_base</span><span class="special">::</span><span class="identifier">floatfield</span> <span class="special">);</span>
+ <span class="identifier">boost</span><span class="special">::</span><span class="identifier">io</span><span class="special">::</span><span class="identifier">ios_precision_saver</span> <span class="identifier">ips</span><span class="special">(</span> <span class="identifier">os</span> <span class="special">);</span>
+ <span class="identifier">os</span><span class="special">.</span><span class="identifier">precision</span><span class="special">(</span> <span class="identifier">places</span> <span class="special">);</span>
+
+ <span class="keyword">for</span> <span class="special">(</span> <span class="special">;</span> <span class="special">*</span><span class="identifier">format</span><span class="special">;</span> <span class="special">++</span><span class="identifier">format</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">if</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">format</span> <span class="special">!=</span> <span class="char">'%'</span> <span class="special">||</span> <span class="special">!*(</span><span class="identifier">format</span><span class="special">+</span><span class="number">1</span><span class="special">)</span> <span class="special">||</span> <span class="special">!</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">strchr</span><span class="special">(</span><span class="string">"acsv"</span><span class="special">,</span> <span class="special">*(</span><span class="identifier">format</span><span class="special">+</span><span class="number">1</span><span class="special">))</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="identifier">os</span> <span class="special"><<</span> <span class="special">*</span><span class="identifier">format</span><span class="special">;</span>
+ <span class="special">}</span> <span class="keyword">else</span> <span class="special">{</span>
+ <span class="special">++</span><span class="identifier">format</span><span class="special">;</span>
+ <span class="keyword">switch</span> <span class="special">(</span> <span class="special">*</span><span class="identifier">format</span> <span class="special">)</span> <span class="special">{</span>
+ <span class="keyword">case</span> <span class="char">'s'</span><span class="special">:</span>
+ <span class="identifier">os</span> <span class="special"><<</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special"><</span><span class="keyword">double</span><span class="special">>(</span><span class="identifier">duration_t</span><span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">sum</span><span class="special">(</span><span class="identifier">acc</span><span class="special">))).</span><span class="identifier">count</span><span class="special">();</span>
+ <span class="keyword">break</span><span class="special">;</span>
+ <span class="keyword">case</span> <span class="char">'a'</span><span class="special">:</span>
+ <span class="identifier">os</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)></span><span class="number">0</span><span class="special">)</span>
+ <span class="special">?</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special"><</span><span class="keyword">double</span><span class="special">>(</span><span class="identifier">duration_t</span><span class="special">(</span><span class="identifier">duration_t</span><span class="special">::</span><span class="identifier">rep</span><span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">mean</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)))).</span><span class="identifier">count</span><span class="special">()</span>
+ <span class="special">:</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">break</span><span class="special">;</span>
+ <span class="keyword">case</span> <span class="char">'c'</span><span class="special">:</span>
+ <span class="identifier">os</span> <span class="special"><<</span> <span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">);</span>
+ <span class="keyword">break</span><span class="special">;</span>
+ <span class="keyword">case</span> <span class="char">'v'</span><span class="special">:</span>
+ <span class="identifier">os</span> <span class="special"><<</span> <span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">count</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)></span><span class="number">0</span><span class="special">)</span>
+ <span class="special">?</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">chrono</span><span class="special">::</span><span class="identifier">duration</span><span class="special"><</span><span class="keyword">double</span><span class="special">>(</span><span class="identifier">duration_t</span><span class="special">(</span><span class="identifier">duration_t</span><span class="special">::</span><span class="identifier">rep</span><span class="special">(</span><span class="identifier">accumulators</span><span class="special">::</span><span class="identifier">variance</span><span class="special">(</span><span class="identifier">acc</span><span class="special">)))).</span><span class="identifier">count</span><span class="special">()</span>
+ <span class="special">:</span> <span class="number">0</span><span class="special">;</span>
+ <span class="keyword">break</span><span class="special">;</span>
+ <span class="keyword">default</span><span class="special">:</span>
+ <span class="identifier">assert</span><span class="special">(</span><span class="number">0</span> <span class="special">&&</span> <span class="string">"my_stopwatch_accumulator_formatter internal logic error"</span><span class="special">);</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+ <span class="special">}</span>
+<span class="special">};</span>
</pre>
</div>
-<div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title">
-<a name="boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_defaul_do_not_satisfy_my_expectations"></a><a href="tutorial.html#boost_chrono.users_guide.tutorial.how_can_i_make_a_specific_formatter_when_the_defaul_do_not_satisfy_my_expectations" title="How
- can I make a specific formatter when the defaul do not satisfy my expectations">How
- can I make a specific formatter when the defaul do not satisfy my expectations</a>
-</h4></div></div></div></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
Modified: sandbox/chrono/libs/chrono/doc/html/index.html
==============================================================================
--- sandbox/chrono/libs/chrono/doc/html/index.html (original)
+++ sandbox/chrono/libs/chrono/doc/html/index.html 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -120,7 +120,7 @@
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: January 22, 2010 at 13:09:37 GMT</small></p></td>
+<td align="left"><p><small>Last revised: January 24, 2010 at 21:03:56 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Modified: sandbox/chrono/libs/chrono/example/specific_stopwatch_accumulator_example.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/specific_stopwatch_accumulator_example.cpp (original)
+++ sandbox/chrono/libs/chrono/example/specific_stopwatch_accumulator_example.cpp 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -78,6 +78,18 @@
, my_stopwatch_accumulator_formatter
> my_stopwatch_accumulator_reporter;
+typedef stopwatch_accumulator<process_real_cpu_clock,
+ accumulator_set<process_real_cpu_clock::rep,
+ features<
+ tag::count,
+ tag::sum,
+ tag::mean,
+ tag::variance(lazy)
+ >
+ >
+ >::get_reporter< my_stopwatch_accumulator_formatter>::type
+ my_stopwatch_accumulator_reporter2;
+
int f1(long j)
{
//static my_stopwatch_accumulator_reporter acc(BOOST_CHRONO_ACCUMULATOR_FUNCTION_FORMAT);
Added: sandbox/chrono/libs/chrono/example/suspendible_stopclock_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/example/suspendible_stopclock_example.cpp 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -0,0 +1,39 @@
+// stopclock_example.cpp ---------------------------------------------------//
+
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/chrono for documentation.
+
+#include <boost/thread.hpp>
+#include <boost/chrono/stopclock.hpp>
+#include <boost/chrono/suspendible_clock.hpp>
+#include <cmath>
+
+using namespace boost::chrono;
+double res;
+
+int f1(long j)
+{
+ stopclock<suspendible_clock<process_cpu_clock> > a(9);
+ //stopclock<> b(9);
+
+ for ( long i = 0; i < j; ++i )
+ res+=std::sqrt( 123.456L ); // burn some time
+ //if (j!=0) f1(j-1);
+ //boost::this_thread::sleep(boost::posix_time::milliseconds(10));
+
+ return 0;
+}
+int main()
+{
+ //stopclock<> _(BOOST_CHRONO_TIME_FUNCTION_FORMAT);
+ stopclock<> _(9);
+
+ for (long i =1; i<= 3; ++i)
+ f1(i*100000);
+ std::cout<< res << std::endl;
+ return 0;
+}
Modified: sandbox/chrono/libs/chrono/test/Jamfile.v2
==============================================================================
--- sandbox/chrono/libs/chrono/test/Jamfile.v2 (original)
+++ sandbox/chrono/libs/chrono/test/Jamfile.v2 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -88,10 +88,13 @@
[ run run_timer_test.cpp : : : <library>/boost/system//boost_system : run_timer_test_dll ]
;
- #test-suite "other_clocks"
+ # test-suite "other_clocks"
# :
# [ run test_suspendible_clock.cpp : : : <library>/boost/thread//boost_thread <link>static ]
# [ run test_suspendible_clock.cpp : : : <library>/boost/thread//boost_thread <library>/boost/system//boost_system : test_suspendible_clock_dll ]
+ # [ run ../example/suspendible_stopclock_example.cpp : : : <library>/boost/thread//boost_thread <link>static ]
+ # [ run ../example/suspendible_stopclock_example.cpp : : : <library>/boost/thread//boost_thread <library>/boost/system//boost_system : suspendible_stopclock_example_dll ]
+ # [ run test_thread_clock.cpp : : : <link>static ]
# ;
test-suite "stopwatch"
Added: sandbox/chrono/libs/chrono/test/test_thread_clock.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/test_thread_clock.cpp 2010-01-24 18:54:05 EST (Sun, 24 Jan 2010)
@@ -0,0 +1,37 @@
+// test_thread_clock.cpp ----------------------------------------------------------//
+
+// Copyright 2009 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+
+#include <boost/chrono/thread_clock.hpp>
+#include <boost/type_traits.hpp>
+
+#include <iostream>
+
+using namespace boost::chrono;
+
+void test_thread_clock()
+{
+ std::cout << "thread_clock test" << std::endl;
+ thread_clock::duration delay = milliseconds(5);
+ thread_clock::time_point start = thread_clock::now();
+ while (thread_clock::now() - start <= delay)
+ ;
+ thread_clock::time_point stop = thread_clock::now();
+ thread_clock::duration elapsed = stop - start;
+ std::cout << "paused " << nanoseconds(elapsed).count() << " nanoseconds\n";
+ start = thread_clock::now();
+ stop = thread_clock::now();
+ std::cout << "thread_clock resolution estimate: " << nanoseconds(stop-start).count() << " nanoseconds\n";
+}
+
+
+int main()
+{
+ test_thread_clock();
+ return 0;
+}
+
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