Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49791 - in sandbox/chrono: boost/chrono libs/chrono/doc libs/chrono/example libs/chrono/src libs/chrono/test libs/chrono/test/chrono_msvc libs/chrono/test/chrono_msvc/run_timer_test
From: bdawes_at_[hidden]
Date: 2008-11-16 09:38:18


Author: bemandawes
Date: 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
New Revision: 49791
URL: http://svn.boost.org/trac/boost/changeset/49791

Log:
Chrono: Initial commit of work-in-progress on process_times, process clock, process_timer, run_timer, and supporting tests and other files.
Added:
   sandbox/chrono/boost/chrono/process_times.hpp (contents, props changed)
   sandbox/chrono/boost/chrono/timer.hpp (contents, props changed)
   sandbox/chrono/libs/chrono/doc/timer.html (contents, props changed)
   sandbox/chrono/libs/chrono/example/run_timer_example.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/example/run_timer_example2.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/example/timex.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/src/process_clock.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/src/run_timer.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/src/run_timer_static.cpp (contents, props changed)
   sandbox/chrono/libs/chrono/test/chrono_msvc/run_timer_test/
   sandbox/chrono/libs/chrono/test/chrono_msvc/run_timer_test/run_timer_test.vcproj (contents, props changed)
   sandbox/chrono/libs/chrono/test/run_timer_test.cpp (contents, props changed)
Text files modified:
   sandbox/chrono/libs/chrono/test/chrono_msvc/chrono_msvc.sln | 6 ++++++
   1 files changed, 6 insertions(+), 0 deletions(-)

Added: sandbox/chrono/boost/chrono/process_times.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/process_times.hpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,166 @@
+// boost process_times.hpp ------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2007, 2008
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// See http://www.boost.org/libs/system for documentation.
+
+#ifndef BOOST_PROCESS_TIMES_HPP
+#define BOOST_PROCESS_TIMES_HPP
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/system/error_code.hpp>
+#include <boost/cstdint.hpp>
+#include <string>
+#include <ostream>
+
+#include <boost/config/abi_prefix.hpp> // must be the last #include
+
+namespace boost
+{
+ namespace chrono
+ {
+
+//---------------------------------------------------------------------------------//
+// process_times //
+//---------------------------------------------------------------------------------//
+
+ struct process_times
+ {
+ nanoseconds real; // real time
+ nanoseconds user; // user cpu time
+ nanoseconds system; // system cpu time
+ };
+
+//---------------------------------------------------------------------------------//
+// process_clock //
+//---------------------------------------------------------------------------------//
+
+ class BOOST_CHRONO_DECL process_clock
+ {
+ public:
+ typedef nanoseconds duration;
+ typedef duration::rep rep;
+ typedef duration::period period;
+ typedef chrono::time_point<process_clock> time_point;
+ static const bool is_monotonic = true;
+
+ static void now( process_times & times,
+ system::error_code & ec = system::throws );
+ };
+
+//---------------------------------------------------------------------------------//
+// process_timer //
+//---------------------------------------------------------------------------------//
+
+ class process_timer
+ {
+ public:
+
+ explicit process_timer( system::error_code & ec = system::throws )
+ {
+ start(ec);
+ }
+
+ ~process_timer() {} // never throws
+
+ void start( system::error_code & ec = system::throws )
+ {
+ process_clock::now( m_start, ec );
+ }
+
+ void elapsed( process_times & times, system::error_code & ec = system::throws )
+ {
+ process_times end;
+ process_clock::now( end, ec );
+ times.real = end.real - m_start.real;
+ times.user = end.user - m_start.user;
+ times.system = end.system - m_start.system;
+ }
+
+ protected:
+ process_times m_start;
+ };
+
+//---------------------------------------------------------------------------------//
+// run_timer //
+//---------------------------------------------------------------------------------//
+
+ class BOOST_CHRONO_DECL run_timer : public process_timer
+ {
+ public:
+
+ // each constructor form has two overloads to avoid a visible default to
+ // std::cout, which in turn would require including <iostream>, with its
+ // high associated cost, even when the standard streams are not used.
+
+ explicit run_timer( system::error_code & ec = system::throws )
+ : m_places(m_default_places), m_os(m_cout()) { start(ec); }
+ explicit run_timer( std::ostream & os,
+ system::error_code & ec = system::throws )
+ : m_places(m_default_places), m_os(os) { start(ec); }
+
+ explicit run_timer( const std::string & format,
+ system::error_code & ec = system::throws )
+ : m_places(m_default_places), m_os(m_cout()), m_format(format) { start(ec); }
+ explicit run_timer( std::ostream & os, const std::string & format,
+ system::error_code & ec = system::throws )
+ : m_places(m_default_places), m_os(os), m_format(format) { start(ec); }
+
+ explicit run_timer( const std::string & format, int places,
+ system::error_code & ec = system::throws )
+ : m_places(places), m_os(m_cout()), m_format(format) { start(ec); }
+ explicit run_timer( std::ostream & os, const std::string & format,
+ int places, system::error_code & ec = system::throws )
+ : m_places(places), m_os(os), m_format(format) { start(ec); }
+
+ explicit run_timer( int places,
+ system::error_code & ec = system::throws )
+ : m_places(places), m_os(m_cout()) { start(ec); }
+ explicit run_timer( std::ostream & os, int places,
+ system::error_code & ec = system::throws )
+ : m_places(places), m_os(os) { start(ec); }
+
+ explicit run_timer( int places, const std::string & format,
+ system::error_code & ec = system::throws )
+ : m_places(places), m_os(m_cout()), m_format(format) { start(ec); }
+ explicit run_timer( std::ostream & os, int places, const std::string & format,
+ system::error_code & ec = system::throws )
+ : m_places(places), m_os(os), m_format(format) { start(ec); }
+
+ ~run_timer() // never throws
+ {
+ system::error_code ec;
+ if ( !reported() ) report( ec );
+ }
+
+ void start( system::error_code & ec = system::throws )
+ {
+ m_reported = false;
+ process_timer::start( ec );
+ }
+
+ void report( system::error_code & ec = system::throws );
+
+ bool reported() const { return m_reported; }
+
+ static int default_places() { return m_default_places; }
+
+ private:
+ int m_places;
+ std::ostream & m_os;
+ std::string m_format;
+ bool m_reported;
+
+ static std::ostream & m_cout();
+ static const int m_default_places = 3;
+ };
+
+ } // namespace chrono
+} // namespace boost
+
+#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
+
+#endif // BOOST_PROCESS_TIMES_HPP

Added: sandbox/chrono/boost/chrono/timer.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/chrono/timer.hpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,53 @@
+// boost/chrono/timer.hpp -------------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/system for documentation.
+
+#ifndef BOOST_CHRONO_TIMER_HPP
+#define BOOST_CHRONO_TIMER_HPP
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/system/error_code.hpp>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+//---------------------------------------------------------------------------------//
+// timer //
+//---------------------------------------------------------------------------------//
+
+// TODO: enable commented out ec
+
+ template <class Clock>
+ class timer
+ {
+ public:
+ typedef Clock clock;
+ typedef typename Clock::time_point time_point;
+ typedef typename Clock::duration duration;
+
+ explicit timer( system::error_code & ec = system::throws )
+ { start(ec); }
+
+ ~timer() {} // never throws
+
+ void start( system::error_code & ec = system::throws )
+ { m_start = clock::now(/*ec*/); }
+
+ duration elapsed( system::error_code & ec = system::throws )
+ { return clock::now(/*ec*/) - m_start; }
+
+ private:
+ time_point m_start;
+ };
+
+ } // namespace chrono
+} // namespace boost
+
+#endif

Added: sandbox/chrono/libs/chrono/doc/timer.html
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/doc/timer.html 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,431 @@
+<html>
+
+<head>
+<meta http-equiv="Content-Language" content="en-us">
+<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
+<meta name="ProgId" content="FrontPage.Editor.Document">
+<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
+<title>Boost System Timers</title>
+</head>
+
+<body>
+
+<h1><img border="0" src="../../../boost.png" align="center" width="277" height="86">
+Boost System Timers<br>
+<a name="Introduction">Introduction</a></h1>
+<p>Knowing how long a program takes to execute is useful in both test and
+production environments. It is also helpful if such timing information is broken down
+into wall clock time, CPU time spent by the user, and CPU time spent by the
+operating system servicing user requests.</p>
+<p>The Boost System Library's timer components provide that information:</p>
+<ul>
+ <li>At the highest level, class <code>run_timer</code> provides a
+ complete run time reporting package that can be invoked in a single line of
+ code.<br>
+&nbsp;</li>
+ <li>At a middle level, class <code>timer</code> provides a widely useful timer
+ object abstraction.<br>
+&nbsp;</li>
+ <li>At the lowest level, two <code>times</code> functions provide
+ thin wrappers around the operating system's process timer API.</li>
+</ul>
+
+<h2><a name="Example">Example</a>s</h2>
+
+<p>Here is the run_timer_example.cpp
+program supplied with the Boost System library:</p>
+<blockquote>
+ <pre>#include &lt;boost/system/timer.hpp&gt;
+#include &lt;cmath&gt;
+
+int main()
+{
+ boost::system::run_timer t;
+
+ for ( long i = 0; i &lt; 10000000; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+}</pre>
+</blockquote>
+<p>When the <code>run_timer t</code> object is created, it starts timing. When
+it is destroyed at the end of the program, its destructor stops the timer and
+displays timing information on cout.</p>
+<p>The output of this program run on a circa 2006 processor looks was this:</p>
+<p><code>&nbsp;&nbsp; wall 0.42 s, user 0.41 s + system 0.00 s = total cpu 0.41 s,
+(96.3%)</code></p>
+<p>In other words, this program ran in 0.42 seconds as would be measured by a
+clock on the wall, the operating system charged it for 0.41 seconds of user CPU
+time and 0 seconds of system CPU time, the total of these two was 0.41, and that
+represented 96.3 percent of the wall clock time.</p>
+
+<p>The run_timer_example2.cpp
+program is the same, except that it supplies additional constructor arguments
+from the command line:</p>
+<blockquote>
+ <pre>#include &lt;boost/system/timer.hpp&gt;
+#include &lt;cmath&gt;
+
+int main( int argc, char * argv[] )
+{
+ const char * format = argc &gt; 1 ? argv[1] : &quot;%t cpu seconds\n&quot;;
+ int places = argc &gt; 2 ? std::atoi( argv[2] ) : 2;
+
+ boost::system::run_timer t( format, places );
+
+ for ( long i = 0; i &lt; 10000000; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+}</pre>
+</blockquote>
+<p>Here is the output for this program for several sets of command line
+arguments:</p>
+<blockquote>
+ <pre>run_timer_example2
+0.42 cpu seconds
+
+run_timer_example2 &quot;%w wall clock seconds\n&quot;
+0.41 wall clock seconds
+
+run_timer_example2 &quot;%w wall clock seconds\n&quot; 6
+0.421875 wall clock seconds
+
+run_timer_example2 &quot;%t total CPU seconds\n&quot; 3
+0.422 total CPU seconds</pre>
+</blockquote>
+<h2>Header
+<font size="5">boost/system/timer.hpp
+synopsis</font></h2>
+<pre>namespace boost
+{
+ namespace system
+ {
+ typedef <i>implementation-defined</i> microsecond_t;
+
+ struct times_t;
+ class timer;
+ class run_timer;
+
+ struct times_t
+ {
+ microsecond_t wall;
+ microsecond_t user;
+ microsecond_t system;
+ };
+
+ // low-level functions --------------------------------------------//
+
+ void times( times_t &amp; result );
+ error_code &amp; times( times_t &amp; result, error_code &amp; ec );
+
+ // class timer ----------------------------------------------------//
+
+ class timer
+ {
+ public:
+
+ timer();
+ timer( const std::nothrow_t &amp; );
+ ~timer();
+
+ void start();
+ const times_t &amp; stop();
+ bool stopped() const;
+ void elapsed( times_t &amp; result );
+
+ private:
+ times_t m_times; // <i><b>exposition only</b></i>
+ };
+
+ // class run_timer ------------------------------------------------//
+
+ class run_timer : public timer
+ {
+ public:
+ explicit run_timer( int places = 2 );
+ run_timer( int places, std::ostream &amp; os );
+
+ explicit run_timer( const std::string &amp; format, int places = 2 );
+ run_timer( const std::string &amp; format, int places, std::ostream &amp; os );
+
+ ~run_timer();
+
+ void report();
+ error_code report( error_code &amp; ec ); // never throws
+
+ private:
+ int m_places; // <i><b>exposition only</b></i>
+ std::ostream &amp; m_os; // <i><b>exposition only</b></i>
+ std::string m_format; // <i><b>exposition only</b></i>
+ };
+
+ } // namespace system
+} // namespace boost
+</pre>
+
+<h3>Typedef <a name="microsecond_t"><code>microsecond_t</code></a></h3>
+
+<p>The typedef <code>microsecond_t</code> provides an implementation defined type capable
+of representing microseconds. For POSIX and Windows systems, <code>
+microseconds_t</code> is <code>boost::int_least64_</code>t.</p>
+
+<p>The underlying type is not based on the Boost Date-Time library to avoid a
+dependency on a large library. This design choice may change at some future
+date.</p>
+
+<p>Although <code>microsecond_t</code> is capable of representing .000001
+second, the actual resolution of common operating system timers is often only
+.015 second.</p>
+
+<h3>Struct <a name="times_t"><code>times_t</code></a></h3>
+
+<p>The struct <code>times_t</code> packages three elapsed times:</p>
+
+<ul>
+ <li>Wall clock elapsed time, equivalent to the time that would be recorded by
+ a stopwatch.</li>
+ <li>User central processing unit (CPU) time used by the process, as charged by
+ the operating system.</li>
+ <li>System central processing unit (CPU) time used by the process, as charged
+ by the operating system.</li>
+</ul>
+
+<h3><a name="Non-member-functions">Non-member functions</a></h3>
+
+<p>These low-level functions are thin wrappers around the operating system's API
+process timing function, such as POSIX <code>times()</code> or <code>Windows
+GetProcessTimes()</code>.</p>
+
+<p><code>void times( times_t &amp; result );</code></p>
+
+<blockquote>
+
+<p><i>Effects:</i> Stores wall-clock, process user CPU, and process system CPU times,
+as reported by the operating system's API process timing function, in r<code>esult</code>.</p>
+
+<p><i>Throws:</i> <code>boost::system::system::error</code> if the underlying
+operating system API call reports an error.</p>
+
+</blockquote>
+
+<p><code>error_code &amp; times( times_t &amp; result, error_code &amp; ec );</code></p>
+
+<blockquote>
+
+<p><i>Effects:</i> Stores wall-clock, process user CPU, and process system CPU times,
+as reported by the operating system's API process timing function, in r<code>esult</code>.
+If the API call reports an error, sets <code>ec</code> accordingly. Otherwise,
+calls <code>ec.clear()</code>.</p>
+
+</blockquote>
+
+<h3>Class <code><a name="timer">timer</a></code></h3>
+
+<p>A <code>timer</code> object measures wall-clock elapsed time, process elapsed
+time charged to the user, and process elapsed time charged to the system.</p>
+
+<p>Unless otherwise specified, all member functions report errors by throwing <code>system_error</code>
+exceptions. If an error occurs and an exception is not thrown, errors are
+reported by setting time values to -1.</p>
+
+<p>The semantics of member functions are achieved by calling the <code>
+times()</code> function.</p>
+
+<h3>Class <a name="cpu_timer_members"><code>timer</code> members</a></h3>
+
+<p><code>timer();</code></p>
+
+<blockquote>
+<p><i>Effects:</i> <code>start()</code>.</p>
+
+</blockquote>
+
+<p><code>timer( const std::nothrow_t &amp; );</code></p>
+
+<blockquote>
+<p><i>Effects:</i> <code>start()</code>.</p>
+
+<p><i>Remarks:</i> Member functions for this object will not throw exceptions.</p>
+
+<p><i>Note: </i>On popular operating systems, such as POSIX and Windows, the question of how to handle errors is moot
+since timer errors do no occur. For programs which may
+run on systems that may possibly report timer errors, the <code>nothrow</code>
+constructor allows suppression of exceptions without the interface thickening
+that would be required if all functions had <code>error_code</code> returning
+variations. In the rare cases where exceptions are undesirable yet the <code>
+error_code</code> must be captured,&nbsp; the non-member <code>times</code>
+function's overload returning an <code>error_code</code> can be used.</p>
+
+</blockquote>
+<p><code>~timer();</code></p>
+
+<blockquote>
+<p><i>Effects:</i> None.</p>
+
+<p><i>Throws:</i> Never.</p>
+
+</blockquote>
+<p><code>void start();</code></p>
+
+<blockquote>
+<p><i>Effects:</i> Begins measuring
+wall-clock, user process, and system process elapsed time.</p>
+
+<p><i>Postconditions:</i> <code>stopped() == false</code>.</p>
+
+</blockquote>
+<p><code>const times_t &amp; stop();</code></p>
+
+<blockquote>
+<p><i>Effects:</i> If <code>!stopped()</code>, stops measuring wall-clock, user
+CPU, and system CPU elapsed time, and stores in a <code>time_t</code> struct the time
+elapsed since the
+preceding invocation of <code>start()</code>. Otherwise, has no effect.</p>
+
+<p><i>Returns:</i> A reference to the <code>time_t</code> struct.</p>
+
+<p><i>Postconditions:</i> <code>stopped() == true</code>.</p>
+
+</blockquote>
+
+<p><code>bool stopped() const;</code></p>
+
+<blockquote>
+
+<p><i>Returns:</i> true if <code>stop()</code> has been called subsequent to a call to
+<code>start()</code>, else <code>false</code>.</p>
+
+</blockquote>
+
+<p><code>void elapsed( times_t &amp; result );</code></p>
+
+<blockquote>
+
+<p><i>Effects:</i> Stores wall-clock, process user CPU, and process system CPU elapsed times
+in r<code>esult</code>.
+If <code>stopped() == false,</code> the times are those measured since the
+preceding invocation of <code>start()</code>, otherwise the times are those
+stored by the preceding invocation of <code>stop()</code>.</p>
+
+<p><i>Remark:</i> Does not call <code>stop()</code>.</p>
+
+</blockquote>
+
+<h3>Class <a name="run_timer">run_timer</a></h3>
+
+<p>Class <code>run_timer</code> inherits publicly from <code><a href="#timer">
+timer</a></code>. For the description of inherited functions, see
+Class timer.</p>
+
+<h3>Class run_timer members</h3>
+
+<pre>explicit run_timer( int places = 2 );</pre>
+<blockquote>
+ <p><i>Effects:</i> Constructs an object of type <code>run_timer</code>.</p>
+ <p><i>Postconditions:<br>
+ </i><code>&nbsp; m_places == places,<br>
+&nbsp; m_os == std::cout,<br>
+&nbsp; m_format == &quot;\nwall %w s, user %u s + system %s s = total cpu %t s, %p%
+ util\n&quot;</code></p>
+</blockquote>
+<pre>run_timer( int places, std::ostream &amp; os );</pre>
+<blockquote>
+ <p><i>Effects:</i> Constructs an object of type <code>run_timer</code>.</p>
+ <p><i>Postconditions:<br>
+ </i><code>&nbsp; m_places == places,<br>
+&nbsp; m_os == os,<br>
+&nbsp; m_format == &quot;\nwall %w s, user %u s + system %s s = total cpu %t s, %p%
+ util\n&quot;</code></p>
+</blockquote>
+<pre>explicit run_timer( const std::string &amp; format, int places = 2 );</pre>
+<blockquote>
+ <p><i>Effects:</i> Constructs an object of type <code>run_timer</code>.</p>
+ <p><i>Postconditions:<br>
+ </i><code>&nbsp; m_format == format,<br>
+&nbsp; m_places == places,<br>
+&nbsp; m_os == std::cout&nbsp; </code></p>
+</blockquote>
+<pre>run_timer( const std::string &amp; format, int places, std::ostream &amp; os );</pre>
+<blockquote>
+ <p><i>Effects:</i> Constructs an object of type <code>run_timer</code>.</p>
+ <p><i>Postconditions:<br>
+ </i><code>&nbsp; m_format == format,<br>
+&nbsp; m_places == places,<br>
+&nbsp; m_os == os&nbsp; </code></p>
+</blockquote>
+<pre>~run_timer();</pre>
+<blockquote>
+ <p><i>Effects:</i> <br>
+ <code>&nbsp; error_code ed;<br>
+&nbsp; if ( !stopped() ) report( ec );</code></p>
+<p><i>Throws:</i> Never.</p>
+
+</blockquote>
+<pre>void report();</pre>
+<blockquote>
+ <p><i>Effects:</i> Same as <code>report( error_code &amp; ec )</code>. See below.</p>
+ <p><i>Note: </i>Does throw on errors.</p>
+</blockquote>
+<pre>error_code report( error_code &amp; ec );</pre>
+<blockquote>
+
+<p><i>Effects: </i>Displays times on <code>m_os</code>:</p>
+
+ <ul>
+ <li><code>stop()</code>.</li>
+ <li>Saves <code>m_os</code> <code>ios</code> flags and precision.</li>
+ <li>Sets <code>m_os</code>&nbsp; <code>ios</code> flags and precision as if by:<ul>
+ <li><code>m_os.setf( std::ios_base::fixed, std::ios_base::floatfield )</code></li>
+ <li><code>m_os.precision( m_places )</code></li>
+ </ul>
+ </li>
+ <li>Outputs <code>m_format</code> to <code>m_os</code>, replacing the character
+ sequences shown in the table below with the indicated values.</li>
+ <li>Restores saved <code>iso</code> flags and precision.</li>
+ <li>If an error occurs during output, sets <code>ec</code> to the
+ corresponding error condition. Otherwise, calls <code>ec.clear()</code>.</li>
+</ul>
+
+ <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="39%">
+ <tr>
+ <td width="25%"><b><i>Sequence</i></b></td>
+ <td width="75%"><b><i>Replacement value</i></b></td>
+ </tr>
+ <tr>
+ <td width="25%" align="center"><code>%w</code></td>
+ <td width="75%"><code>wall()</code></td>
+ </tr>
+ <tr>
+ <td width="25%" align="center"><code>%u</code></td>
+ <td width="75%"><code>user()</code></td>
+ </tr>
+ <tr>
+ <td width="25%" align="center"><code>%s</code></td>
+ <td width="75%"><code>system()</code></td>
+ </tr>
+ <tr>
+ <td width="25%" align="center"><code>%t</code></td>
+ <td width="75%"><code>user()+system()</code></td>
+ </tr>
+ <tr>
+ <td width="25%" align="center"><code>%p</code></td>
+ <td width="75%">The percentage of <code>wall()</code> represented by by <code>
+ user()+system()</code></td>
+ </tr>
+ </table>
+ <p><i>Returns:</i> <code>ec</code></p>
+ <p><i>Throws:</i> Never.</p>
+</blockquote>
+
+<hr>
+<p>Last revised:
+<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->19 January, 2008<!--webbot bot="Timestamp" endspan i-checksum="39223" --></p>
+<p>© Copyright Beman Dawes, 2006</p>
+<p>Distributed under the Boost Software License, Version 1.0. (See accompanying
+file LICENSE_1_0.txt or copy at
+www.boost.org/ LICENSE_1_0.txt)</p>
+
+</body>
+
+</html>
\ No newline at end of file

Added: sandbox/chrono/libs/chrono/example/run_timer_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/example/run_timer_example.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,21 @@
+// run_timer_example.cpp ---------------------------------------------------//
+
+// Copyright Beman Dawes 2006
+
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/system for documentation.
+
+#include <boost/system/timer.hpp>
+#include <cmath>
+
+int main()
+{
+ boost::system::run_timer t;
+
+ for ( long i = 0; i < 10000000; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+}

Added: sandbox/chrono/libs/chrono/example/run_timer_example2.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/example/run_timer_example2.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,24 @@
+// run_timer_example2.cpp --------------------------------------------------//
+
+// Copyright Beman Dawes 2006
+
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/system for documentation.
+
+#include <boost/system/timer.hpp>
+#include <cmath>
+
+int main( int argc, char * argv[] )
+{
+ const char * format = argc > 1 ? argv[1] : "%t cpu seconds\n";
+ int places = argc > 2 ? std::atoi( argv[2] ) : 2;
+
+ boost::system::run_timer t( format, places );
+
+ for ( long i = 0; i < 10000000; ++i )
+ std::sqrt( 123.456L ); // burn some time
+
+ return 0;
+}

Added: sandbox/chrono/libs/chrono/example/timex.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/example/timex.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,47 @@
+// timex: timed execution program ------------------------------------------//
+
+// Copyright Beman Dawes 2007
+
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org/libs/system for documentation.
+
+#include <boost/system/timer.hpp>
+#include <cstdlib>
+#include <string>
+#include <iostream>
+
+int main( int argc, char * argv[] )
+{
+ if ( argc == 1 )
+ {
+ std::cout << "invoke: timex [-v] command [args...]\n"
+ " command will be executed and timings displayed\n"
+ " -v option causes command and args to be displayed\n";
+ return 1;
+ }
+
+ std::string s;
+
+ bool verbose = false;
+ if ( argc > 1 && *argv[1] == '-' && *(argv[1]+1) == 'v' )
+ {
+ verbose = true;
+ ++argv;
+ --argc;
+ }
+
+ for ( int i = 1; i < argc; ++i )
+ {
+ if ( i > 1 ) s += ' ';
+ s += argv[i];
+ }
+
+ if ( verbose )
+ { std::cout << "command: \"" << s.c_str() << "\"\n"; }
+
+ boost::system::run_timer t;
+
+ return std::system( s.c_str() );
+}

Added: sandbox/chrono/libs/chrono/src/process_clock.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/src/process_clock.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,95 @@
+// boost process_timer.cpp ------------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+
+// 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.
+
+//---------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+#if defined(BOOST_CHRONO_WINDOWS_API)
+# include <windows.h>
+#elif defined(BOOST_CHRONO_POSIX_API)
+# include <sys/times.h>
+#else
+# error unknown API
+#endif
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ void process_clock::now( process_times & times, system::error_code & ec )
+ {
+
+# if defined(BOOST_WINDOWS_API)
+
+ // note that Windows uses 100 nanosecond ticks for FILETIME
+ FILETIME creation, exit, user_time, system_time;
+
+ //FILETIME stopwatch_time;
+ //::GetSystemTimeAsFileTime( &stopwatch_time );
+ //times.real = duration(
+ // ((static_cast<time_point::rep>(stopwatch_time.dwHighDateTime) << 32)
+ // | stopwatch_time.dwLowDateTime) * 100 );
+
+ times.real = duration( monotonic_clock::now().time_since_epoch().count() );
+
+ if ( ::GetProcessTimes( ::GetCurrentProcess(), &creation, &exit,
+ &system_time, &user_time ) )
+ {
+ times.user = duration(
+ ((static_cast<time_point::rep>(user_time.dwHighDateTime) << 32)
+ | user_time.dwLowDateTime) * 100 );
+
+ times.system = duration(
+ ((static_cast<time_point::rep>(system_time.dwHighDateTime) << 32)
+ | system_time.dwLowDateTime) * 100 );
+ }
+ else
+ {
+ assert( 0 && "error handling not implemented yet" );
+ //ec = error_code( ::GetLastError(), native_ecat );
+ //current.wall = current.system = current.user = microsecond_t(-1);
+ }
+
+# else
+ tms tm;
+ clock_t c = ::times( &tm );
+ if ( c == -1 ) // error
+ {
+ ec = error_code( errno, native_ecat );
+ current.wall = current.system = current.user = microsecond_t(-1);
+ }
+ else
+ {
+ current.wall = microsecond_t(c);
+ current.system = microsecond_t(tm.tms_stime + tm.tms_cstime);
+ current.user = microsecond_t(tm.tms_utime + tm.tms_cutime);
+ if ( tick_factor() != -1 )
+ {
+ current.wall *= tick_factor();
+ current.user *= tick_factor();
+ current.system *= tick_factor();
+ }
+ else
+ {
+ ec = error_code( errno, native_ecat );
+ current.wall = current.user = current.system = microsecond_t(-1);
+ }
+ }
+# endif
+ }
+ } // namespace chrono
+} // namespace boost

Added: sandbox/chrono/libs/chrono/src/run_timer.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/src/run_timer.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,174 @@
+// boost run_timer.cpp -----------------------------------------------------//
+
+// Copyright Beman Dawes 1994, 2006, 2008
+
+// 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.
+
+//----------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/process_times.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/io/ios_state.hpp>
+#include <cstring>
+#include <cassert>
+
+using boost::chrono::nanoseconds;
+using boost::chrono::duration;
+
+namespace
+{
+ const char * default_format =
+ "\nreal %rs, cpu %cs (%p%), user %us, system %ss\n";
+
+//# if defined(BOOST_POSIX_API)
+// long tick_factor() // multiplier to convert ticks
+// // to nanoseconds; -1 if unknown
+// {
+// static long tick_factor = 0;
+// if ( !tick_factor )
+// {
+// if ( (tick_factor = ::sysconf( _SC_CLK_TCK )) <= 0 )
+// tick_factor = -1;
+// else
+// {
+// assert( tick_factor <= 1000000L ); // doesn't handle large ticks
+// tick_factor = 1000000L / tick_factor; // compute factor
+// if ( !tick_factor ) tick_factor = -1;
+// }
+// }
+// return tick_factor;
+// }
+//# endif
+
+ const long long scale[10] = { 1000000000LL, 100000000LL, 10000000LL,
+ 1000000LL, 100000LL, 10000LL, 1000LL, 100LL, 10LL, 1LL };
+
+ void fixed_point_nano( std::ostream & os, long long value, int places )
+ {
+ if ( places > 0 )
+ {
+ os << value / 1000000000LL
+ << '.'; // TODO: get appropriate char from locale
+ os.width( places );
+ value %= 1000000000LL;
+ value /= scale[places];
+ os << value;
+ }
+ else
+ {
+ os << value;
+ }
+ }
+
+ void show_time( const boost::chrono::process_times & times,
+ const char * format, int places, std::ostream & os )
+ //// NOTE WELL: Will truncate least-significant digits to LDBL_DIG, which may
+ //// be as low as 10, although will be 15 for many common platforms.
+ {
+ if ( times.real < nanoseconds(0) ) return;
+ if ( places > 9 )
+ places = 9; // sanity check
+ else if ( places < 0 )
+ places = 0;
+
+ //boost::io::ios_flags_saver ifs( os );
+ //boost::io::ios_precision_saver ips( os );
+ //os.setf( std::ios_base::fixed, std::ios_base::floatfield );
+ //os.precision( places );
+
+ boost::io::ios_flags_saver ifkgs( os );
+ os.setf(std::ios_base::right, std::ios_base::adjustfield);
+ boost::io::ios_fill_saver ifils( os );
+ os.fill( '0' );
+
+ nanoseconds total = times.system + times.user;
+
+ for ( ; *format; ++format )
+ {
+ if ( *format != '%' || !*(format+1) || !std::strchr("rcpus", *(format+1)) )
+ os << *format;
+ else
+ {
+ ++format;
+ switch ( *format )
+ {
+ case 'r':
+ //os << duration<double>(times.real).count();
+ fixed_point_nano( os, times.real.count(), places );
+ break;
+ case 'u':
+ //os << duration<double>(times.user).count();
+ fixed_point_nano( os, times.user.count(), places );
+ break;
+ case 's':
+ //os << duration<double>(times.system).count();
+ fixed_point_nano( os, times.system.count(), places );
+ break;
+ case 'c':
+ //os << duration<double>(total).count();
+ fixed_point_nano( os, total.count(), places );
+ break;
+ case 'p':
+ {
+ boost::io::ios_precision_saver ips( os );
+ os.setf( std::ios_base::fixed, std::ios_base::floatfield );
+ os.precision( 1 );
+ if ( times.real.count() && total.count() )
+ os << duration<double>(total).count()
+ /duration<double>(times.real).count() * 100.0;
+ else
+ os << 0.0;
+ }
+ break;
+ default:
+ assert(0 && "run_timer internal logic error");
+ }
+ }
+ }
+ }
+
+} // unnamed namespace
+
+namespace boost
+{
+ namespace chrono
+ {
+ // run_timer:: report --------------------------------------//
+
+ void run_timer::report( system::error_code & ec )
+ {
+ m_reported = true;
+ if ( m_format.empty() ) m_format = default_format;
+
+ process_times times;
+ elapsed( times, ec );
+
+ if ( &ec == &system::throws )
+ {
+ show_time( times, m_format.c_str(), m_places, m_os );
+ }
+ else // non-throwing
+ {
+ try
+ {
+ show_time( times, m_format.c_str(), m_places, m_os );
+ ec = system::error_code();
+ }
+
+ catch (...) // eat any exceptions
+ {
+ assert( 0 && "error reporting not fully implemented yet" );
+ //ec = error_code( EIO, errno_ecat );
+ }
+ }
+ }
+
+ } // namespace chrono
+} // namespace boost

Added: sandbox/chrono/libs/chrono/src/run_timer_static.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/src/run_timer_static.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,34 @@
+// boost run_timer_static.cpp ---------------------------------------------------//
+
+// Copyright Beman Dawes 2008
+
+// 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.
+
+//---------------------------------------------------------------------------------//
+
+// This function is defined in a separate translation so that it will not be linked
+// in except if actually used. This is more efficient because header <iostream> is
+// required, and it incurs the cost of the standard stream objects even if they are
+// not actually used.
+
+//---------------------------------------------------------------------------------//
+
+// define BOOST_CHRONO_SOURCE so that <boost/chrono/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_CHRONO_SOURCE
+
+#include <boost/chrono/process_times.hpp>
+#include <iostream>
+
+namespace boost
+{
+ namespace chrono
+ {
+
+ std::ostream & run_timer::m_cout() { return std::cout; }
+
+ } // namespace chrono
+} // namespace boost

Modified: sandbox/chrono/libs/chrono/test/chrono_msvc/chrono_msvc.sln
==============================================================================
--- sandbox/chrono/libs/chrono/test/chrono_msvc/chrono_msvc.sln (original)
+++ sandbox/chrono/libs/chrono/test/chrono_msvc/chrono_msvc.sln 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -7,6 +7,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "await_keystroke", "await_keystroke\await_keystroke.vcproj", "{E0E5B024-EF94-46AE-A848-3973848F2773}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "run_timer_test", "run_timer_test\run_timer_test.vcproj", "{BD153170-B250-4081-A736-603A593B470B}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -25,6 +27,10 @@
                 {E0E5B024-EF94-46AE-A848-3973848F2773}.Debug|Win32.Build.0 = Debug|Win32
                 {E0E5B024-EF94-46AE-A848-3973848F2773}.Release|Win32.ActiveCfg = Release|Win32
                 {E0E5B024-EF94-46AE-A848-3973848F2773}.Release|Win32.Build.0 = Release|Win32
+ {BD153170-B250-4081-A736-603A593B470B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BD153170-B250-4081-A736-603A593B470B}.Debug|Win32.Build.0 = Debug|Win32
+ {BD153170-B250-4081-A736-603A593B470B}.Release|Win32.ActiveCfg = Release|Win32
+ {BD153170-B250-4081-A736-603A593B470B}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Added: sandbox/chrono/libs/chrono/test/chrono_msvc/run_timer_test/run_timer_test.vcproj
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/chrono_msvc/run_timer_test/run_timer_test.vcproj 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="run_timer_test"
+ ProjectGUID="{BD153170-B250-4081-A736-603A593B470B}"
+ RootNamespace="run_timer_test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\common.vsprops"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="..\common.vsprops"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\..\..\src\chrono.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\system\src\error_code.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\process_clock.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\run_timer.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\src\run_timer_static.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\run_timer_test.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>

Added: sandbox/chrono/libs/chrono/test/run_timer_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/test/run_timer_test.cpp 2008-11-16 09:38:17 EST (Sun, 16 Nov 2008)
@@ -0,0 +1,96 @@
+// boost run_timer_test.cpp -----------------------------------------------------//
+
+// Copyright Beman Dawes 2006, 2008
+
+// 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/chrono/process_times.hpp>
+#include <boost/chrono/timer.hpp>
+#include <cstdlib> // for atol()
+#include <iostream>
+#include <locale>
+
+using boost::chrono::run_timer;
+using boost::system::error_code;
+
+namespace
+{
+
+ void run_timer_constructor_overload_test()
+ {
+ // exercise each supported combination of constructor arguments
+
+ std::ostream & os = std::cout;
+ int pl = 6;
+ boost::system::error_code ec;
+
+ run_timer t1;
+ run_timer t2( os );
+ run_timer t3( ec );
+ run_timer t4( os, ec );
+ run_timer t5( pl );
+ run_timer t6( os, pl );
+ run_timer t7( pl, ec );
+ run_timer t8( os, pl, ec );
+ run_timer t9( "t9, default places, r %r, c %c, p %p, u %u, s %s\n" );
+ run_timer t10( os, "t10, default places, r %r, c %c, p %p, u %u, s %s\n" );
+ run_timer t11( "t11, default places, r %r, c %c, p %p, u %u, s %s\n", ec );
+ run_timer t12( os, "t12, default places, r %r, c %c, p %p, u %u, s %s\n", ec );
+ run_timer t13( pl, "t13, 6 places, r %r, c %c, p %p, u %u, s %s\n" );
+ run_timer t14( "t14, 6 places, r %r, c %c, p %p, u %u, s %s\n", pl );
+ run_timer t15( os, pl, "t15, 6 places, r %r, c %c, p %p, u %u, s %s\n" );
+ run_timer t16( os, "t16, 6 places, r %r, c %c, p %p, u %u, s %s\n", pl );
+ run_timer t17( pl, "t17, 6 places, r %r, c %c, p %p, u %u, s %s\n", ec );
+ run_timer t18( "t18, 6 places, r %r, c %c, p %p, u %u, s %s\n", pl, ec );
+ run_timer t19( os, pl, "t19, 6 places, r %r, c %c, p %p, u %u, s %s\n", ec );
+ run_timer t20( os, "t20, 6 places, r %r, c %c, p %p, u %u, s %s\n", pl, ec );
+
+ std::cout << "Burn some time so run_timers have something to report...";
+ boost::chrono::timer<boost::chrono::high_resolution_clock> t;
+ while ( t.elapsed() < boost::chrono::seconds(1) ) {}
+ std::cout << "\n";
+ std::cout << "default places is " << run_timer::default_places() << "\n";
+
+ }
+}
+
+int main( int argc, char * argv[] )
+{
+ //std::locale loc( "" );
+ //std::cout.imbue( loc );
+
+ run_timer_constructor_overload_test();
+
+ //run_timer timer(6);
+ //run_timer timer2("\nrtc %r sec, utilization %p%\n");
+ //run_timer timer3("\nrtc %r sec, total cpu %c sec, utilization %p%\n", 3);
+
+ //long count = 0;
+ //times_t times;
+ //times.real = 0;
+ //microsecond_t timeout
+ // = microsecond_t(500000); // default .5 seconds
+
+ //if ( argc > 1 ) timeout = microsecond_t(std::atol( argv[1] ));
+
+ //while ( times.real < timeout )
+ //{
+ // // The point of this code is to burn both kernal and user cpu time,
+ // // with the total less than wall clock time.
+ // ++count;
+ // timer.elapsed( times );
+ // // sleep(1);
+ // std::cout << "iteration " << count << ", "
+ // << times.real << " real, "
+ // << times.user << " user, "
+ // << times.system << " system microsecs"
+ // << std::endl;
+ //}
+
+ //std::cout << count << " iterations\n";
+ 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