$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: bdawes_at_[hidden]
Date: 2007-08-27 20:08:41
Author: bemandawes
Date: 2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
New Revision: 39028
URL: http://svn.boost.org/trac/boost/changeset/39028
Log:
Initial commit to public repository. Earlier version in Beman Dawes private SVN.
Added:
   sandbox/libs/system/
   sandbox/libs/system/build/
   sandbox/libs/system/build/Jamfile.v2   (contents, props changed)
   sandbox/libs/system/doc/
   sandbox/libs/system/doc/timer.html   (contents, props changed)
   sandbox/libs/system/example/
   sandbox/libs/system/example/run_timer_example.cpp   (contents, props changed)
   sandbox/libs/system/example/run_timer_example2.cpp   (contents, props changed)
   sandbox/libs/system/example/timex.cpp   (contents, props changed)
   sandbox/libs/system/src/
   sandbox/libs/system/src/run_timer.cpp   (contents, props changed)
   sandbox/libs/system/src/run_timer_ctors.cpp   (contents, props changed)
   sandbox/libs/system/src/timer.cpp   (contents, props changed)
   sandbox/libs/system/test/
   sandbox/libs/system/test/Jamfile.v2   (contents, props changed)
   sandbox/libs/system/test/timer_test.cpp   (contents, props changed)
Added: sandbox/libs/system/build/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/libs/system/build/Jamfile.v2	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -0,0 +1,20 @@
+# Boost System Library Build Jamfile
+
+# (C) Copyright Beman Dawes 2002, 2006
+
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or www.boost.org/LICENSE_1_0.txt)
+
+# See library home page at http://www.boost.org/libs/system
+
+project boost/system
+    : source-location ../src
+    ;
+
+SOURCES = run_timer run_timer_ctors timer ;
+
+lib boost_system
+   : $(SOURCES).cpp
+   : <link>shared:<define>BOOST_SYSTEM_DYN_LINK=1
+     <link>static:<define>BOOST_SYSTEM_STATIC_LINK=1
+   ;
Added: sandbox/libs/system/doc/timer.html
==============================================================================
--- (empty file)
+++ sandbox/libs/system/doc/timer.html	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -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>
+ </li>
+  <li>At a middle level, class <code>timer</code> provides a widely useful timer 
+  object abstraction.<br>
+ </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 <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;
+}</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>   wall 0.42 s, user 0.41 s + system 0.00 s = total cpu 0.41 s, 
+96.3% util</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 <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;
+}</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 "%w wall clock seconds\n"
+0.41 wall clock seconds
+
+run_timer_example2 "%w wall clock seconds\n" 6
+0.421875 wall clock seconds
+
+run_timer_example2 "%t total CPU seconds\n" 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 & result );
+    error_code & times( times_t & result, error_code & ec );
+
+    // class timer ----------------------------------------------------//
+
+    class timer
+    {
+    public:
+
+      timer();
+      timer( const std::nothrow_t & );
+     ~timer();
+
+      void             start();
+      const times_t &  stop();
+      bool             stopped() const;
+      void             elapsed( times_t & 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 & os );
+
+      explicit run_timer( const std::string & format, int places = 2 );
+      run_timer( const std::string & format, int places, std::ostream & os );
+
+     ~run_timer();
+
+      void        report();
+      error_code  report( error_code & ec ); // never throws
+
+    private:
+      int             m_places;  // <i><b>exposition only</b></i>
+      std::ostream &  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 & 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 & times( times_t & result, error_code & 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 & );</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,  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 & 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 & 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>  m_places == places,<br>
+  m_os == std::cout,<br>
+  m_format == "\nwall %w s, user %u s + system %s s = total cpu %t s, %p% 
+  util\n"</code></p>
+</blockquote>
+<pre>run_timer( int places, std::ostream & os );</pre>
+<blockquote>
+  <p><i>Effects:</i> Constructs an object of type <code>run_timer</code>.</p>
+  <p><i>Postconditions:<br>
+  </i><code>  m_places == places,<br>
+  m_os == os,<br>
+  m_format == "\nwall %w s, user %u s + system %s s = total cpu %t s, %p% 
+  util\n"</code></p>
+</blockquote>
+<pre>explicit run_timer( const std::string & 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>  m_format == format,<br>
+  m_places == places,<br>
+  m_os == std::cout  </code></p>
+</blockquote>
+<pre>run_timer( const std::string & format, int places, std::ostream & os );</pre>
+<blockquote>
+  <p><i>Effects:</i> Constructs an object of type <code>run_timer</code>.</p>
+  <p><i>Postconditions:<br>
+  </i><code>  m_format == format,<br>
+  m_places == places,<br>
+  m_os == os  </code></p>
+</blockquote>
+<pre>~run_timer();</pre>
+<blockquote>
+  <p><i>Effects:</i> <br>
+  <code>  error_code ed;<br>
+  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 & ec )</code>. See below.</p>
+  <p><i>Note: </i>Does throw on errors.</p>
+</blockquote>
+<pre>error_code report( error_code & 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>  <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 -->17 August, 2007<!--webbot bot="Timestamp" endspan i-checksum="34739" --></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/libs/system/example/run_timer_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/example/run_timer_example.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -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/libs/system/example/run_timer_example2.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/example/run_timer_example2.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -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/libs/system/example/timex.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/example/timex.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -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/libs/system/src/run_timer.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/src/run_timer.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -0,0 +1,146 @@
+//  boost run_timer.cpp  -----------------------------------------------------//
+
+//  Copyright Beman Dawes 1994-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.
+
+//----------------------------------------------------------------------------//
+
+// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_SYSTEM_SOURCE 
+
+#include <boost/system/timer.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/io/ios_state.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/cerrno.hpp>
+#include <cstring>
+#include <cassert>
+
+using boost::system::microsecond_t;
+using boost::system::times_t;
+
+# if defined(BOOST_WINDOWS_API)
+#   include <windows.h>
+# elif defined(BOOST_POSIX_API)
+#   include <sys/times.h>
+# else
+# error unknown API
+# endif
+
+namespace
+{
+  const char * default_format =
+    "\nwall %w s, user %u s + system %s s = total cpu %t s, %p% util\n";
+
+# if defined(BOOST_POSIX_API)
+  long tick_factor()        // multiplier to convert ticks
+                             //  to microseconds; -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
+
+void show_time( const char * format, int places, std::ostream & os,
+    const times_t & times )
+  //  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.wall < microsecond_t(0) ) return;
+    if ( places > 6 ) places = 6;
+    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 );
+
+    const long double sec = 1000000.0L;
+    microsecond_t total = times.system + times.user;
+
+    for ( ; *format; ++format )
+    {
+      if ( *format != '%' || !*(format+1) || !std::strchr("wustp", *(format+1)) )
+        os << *format;
+      else
+      {
+        ++format;
+        switch ( *format )
+        {
+        case 'w':
+          os << times.wall / sec;
+          break;
+        case 'u':
+          os << times.user / sec;
+          break;
+        case 's':
+          os << times.system / sec;
+          break;
+        case 't':
+          os << total / sec;
+          break;
+        case 'p':
+          os.precision( 1 );
+           if ( times.wall && total )
+             os << static_cast<long double>(total) /times. wall * 100.0;
+           else
+             os << 0.0;
+          os.precision( places );
+          break;
+        default:
+          assert(0);
+        }
+      }
+    }
+  }
+
+}  // unnamed namespace
+
+namespace boost
+{
+  namespace system
+  {
+    //  run_timer:: report  --------------------------------------//
+
+    void run_timer::report()
+    {
+      show_time( m_format.empty() 
+          ? default_format
+          : m_format.c_str(),
+        m_places, m_os, this->stop() );
+    }
+
+    error_code run_timer::report( error_code & ec )
+    {
+      try
+      {
+        report();
+        ec = error_code();
+      }
+
+      catch (...) // eat any exceptions
+      {
+        ec = error_code( EIO, errno_ecat );
+      } 
+      
+      return ec;
+    }
+
+  } // namespace system
+} // namespace boost
Added: sandbox/libs/system/src/run_timer_ctors.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/src/run_timer_ctors.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -0,0 +1,37 @@
+//  boost run_timer_ctors.cpp  -----------------------------------------------//
+
+//  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.
+
+//----------------------------------------------------------------------------//
+
+//  These constructors are in a separate file so that this translation unit will
+//  not be linked in except when one of the constructors is actually used. This
+//  is important since header <iostream> is required, and it incurs the cost of
+//  the standard stream objects even if they are not used.
+
+//----------------------------------------------------------------------------//
+
+// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_SYSTEM_SOURCE 
+
+#include <boost/system/timer.hpp>
+#include <iostream>
+
+namespace boost
+{
+  namespace system
+  {
+    run_timer::run_timer( int places )
+        : m_places(places), m_os(std::cout) {}
+
+    run_timer::run_timer( const std::string & format, int places )
+        : m_places(places), m_os(std::cout), m_format(format) {}
+
+  } // namespace system
+} // namespace boost
Added: sandbox/libs/system/src/timer.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/src/timer.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -0,0 +1,141 @@
+//  boost timer.cpp  ---------------------------------------------------------//
+
+//  Copyright Beman Dawes 1994-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.
+
+//----------------------------------------------------------------------------//
+
+// define BOOST_SYSTEM_SOURCE so that <boost/system/config.hpp> knows
+// the library is being built (possibly exporting rather than importing code)
+#define BOOST_SYSTEM_SOURCE 
+
+#include <boost/system/timer.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/io/ios_state.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/cerrno.hpp>
+#include <cstring>
+#include <cassert>
+
+# if defined(BOOST_WINDOWS_API)
+#   include <windows.h>
+# elif defined(BOOST_POSIX_API)
+#   include <sys/times.h>
+# else
+# error unknown API
+# endif
+
+namespace boost
+{
+  namespace system
+  {
+
+    BOOST_SYSTEM_DECL
+    void times( times_t & current )
+    {
+      error_code ec;
+      if ( times( current, ec ) )
+        boost::throw_exception( system_error( ec, "boost::system::times" ) );
+    }
+
+    BOOST_SYSTEM_DECL
+    error_code & times( times_t & current, error_code & ec )
+    {
+      ec = error_code();
+#   if defined(BOOST_WINDOWS_API)
+      ::GetSystemTimeAsFileTime( (LPFILETIME)¤t.wall );
+      FILETIME creation, exit;
+      if ( ::GetProcessTimes( ::GetCurrentProcess(), &creation, &exit,
+             (LPFILETIME)¤t.system, (LPFILETIME)¤t.user ) )
+      {
+        current.wall   /= 10;  // Windows uses 100 nanosecond ticks
+        current.user   /= 10;
+        current.system /= 10;
+      }
+      else
+      {
+        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
+      return ec;
+    }
+
+#define  BOOST_TIMES(C)            \
+      if ( m_flags & m_nothrow )   \
+      {                            \
+        error_code ec;             \
+        times( C, ec );            \
+      }                            \
+      else                         \
+        times( C );
+
+    //  timer  ---------------------------------------------------------------//
+
+    void timer::start()
+    {
+      m_flags = static_cast<m_flags_t>(m_flags & ~m_stopped);
+      BOOST_TIMES( m_times );
+    }
+
+    const times_t & timer::stop()
+    {
+      if ( stopped() ) return m_times;
+      m_flags = static_cast<m_flags_t>(m_flags | m_stopped);
+      
+      times_t current;
+      BOOST_TIMES( current );
+      m_times.wall = (current.wall - m_times.wall);
+      m_times.user = (current.user - m_times.user);
+      m_times.system = (current.system - m_times.system);
+      return m_times;
+    }
+
+    void timer::elapsed( times_t & current )
+    {
+      if ( stopped() )
+      {
+        current.wall = m_times.wall;
+        current.user = m_times.user;
+        current.system = m_times.system;
+      }
+      else
+      {
+        BOOST_TIMES( current );
+        current.wall -= m_times.wall;
+        current.user -= m_times.user;
+        current.system -= m_times.system;
+      }
+    }
+
+  } // namespace system
+} // namespace boost
Added: sandbox/libs/system/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/libs/system/test/Jamfile.v2	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -0,0 +1,41 @@
+# Boost System Library test Jamfile
+
+# Copyright Beman Dawes 2003, 2006
+
+# Distributed under the Boost Software License, Version 1.0.
+# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
+
+# See library home page at http://www.boost.org/libs/system
+
+project
+    : requirements
+      <library>/boost/system//boost_system
+      <define>BOOST_ALL_NO_LIB
+    ;
+
+   test-suite "system"
+       : [ run error_code_test.cpp
+           :  :  : <define>BOOST_SYSTEM_STATIC_LINK 
+                   <runtime-link>static <link>static
+         ]
+         [ run error_code_test.cpp
+           :  :  : <define>BOOST_SYSTEM_DYN_LINK 
+                 : error_code_test_dll
+         ]
+         [ run error_code_user_test.cpp
+           :  :  : <define>BOOST_SYSTEM_STATIC_LINK 
+                   <runtime-link>static <link>static
+         ]
+         [ run error_code_user_test.cpp
+           :  :  : <define>BOOST_SYSTEM_DYN_LINK 
+                 : error_code_user_test_dll
+         ]
+         [ run system_error_test.cpp
+           :  :  : <define>BOOST_SYSTEM_STATIC_LINK 
+                   <runtime-link>static <link>static
+         ]
+         [ run system_error_test.cpp
+            :  :  : <define>BOOST_SYSTEM_DYN_LINK 
+                  : system_error_test_dll
+         ]
+         ;
Added: sandbox/libs/system/test/timer_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/libs/system/test/timer_test.cpp	2007-08-27 20:08:40 EDT (Mon, 27 Aug 2007)
@@ -0,0 +1,54 @@
+//  boost timer_test.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 <cstdlib> // for atol()
+#include <iostream>
+#include <locale>
+
+using boost::system::microsecond_t;
+using boost::system::times_t;
+using boost::system::timer;
+using boost::system::run_timer;
+
+int main( int argc, char * argv[] )
+{
+  std::locale loc( "" );
+  std::cout.imbue( loc );
+  
+  run_timer timer(6);
+  run_timer timer2("\nwall %w s, utilization %p%\n");
+  run_timer timer3("\nwall %w s, total cpu %t s, utilization %p%\n", 3);
+
+  long count = 0;
+  times_t times;
+  times.wall = 0;
+  microsecond_t timeout
+    = microsecond_t(500000); // default .5 seconds
+
+  if ( argc > 1 ) timeout = microsecond_t(std::atol( argv[1] ));
+
+  while ( times.wall < 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.wall << " wall, "
+      << times.user << " user, "
+      << times.system << " system microsecs"
+      << std::endl;
+  }
+
+  std::cout << count << " iterations\n";
+  return 0;
+}
+