Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58965 - in sandbox/chrono/libs/chrono: build example src
From: vicente.botet_at_[hidden]
Date: 2010-01-13 06:05:54


Author: viboes
Date: 2010-01-13 06:05:53 EST (Wed, 13 Jan 2010)
New Revision: 58965
URL: http://svn.boost.org/trac/boost/changeset/58965

Log:
Boost.Chrono: Version 0.3.0,
* Added digital_time example using the operator%
* Renamed cpu_clocks to process_cpu_clocks

Added:
   sandbox/chrono/libs/chrono/src/process_cpu_clocks.cpp (contents, props changed)
Text files modified:
   sandbox/chrono/libs/chrono/build/Jamfile.v2 | 4 ++--
   sandbox/chrono/libs/chrono/example/stopwatch_example.cpp | 28 +++++++++++-----------------
   2 files changed, 13 insertions(+), 19 deletions(-)

Modified: sandbox/chrono/libs/chrono/build/Jamfile.v2
==============================================================================
--- sandbox/chrono/libs/chrono/build/Jamfile.v2 (original)
+++ sandbox/chrono/libs/chrono/build/Jamfile.v2 2010-01-13 06:05:53 EST (Wed, 13 Jan 2010)
@@ -41,7 +41,7 @@
         <link>static:<define>BOOST_CHRONO_STATIC_LINK=1
     ;
 
-SOURCES = chrono process_clock run_timer run_timer_static cpu_clocks ;
+SOURCES = chrono process_clock run_timer run_timer_static process_cpu_clocks ;
 
 lib boost_chrono
     : $(SOURCES).cpp
@@ -51,4 +51,4 @@
     <link>static:<define>BOOST_All_STATIC_LINK=1 # tell source we're building static lib's
     ;
 
-#boost-install boost_chrono ;
\ No newline at end of file
+#boost-install boost_chrono ;

Modified: sandbox/chrono/libs/chrono/example/stopwatch_example.cpp
==============================================================================
--- sandbox/chrono/libs/chrono/example/stopwatch_example.cpp (original)
+++ sandbox/chrono/libs/chrono/example/stopwatch_example.cpp 2010-01-13 06:05:53 EST (Wed, 13 Jan 2010)
@@ -11,27 +11,21 @@
 #include <boost/chrono/process_times.hpp>
 #include <boost/chrono/stopwatch.hpp>
 #include <boost/chrono/stopwatch_accumulator.hpp>
-#include <boost/chrono/cpu_clocks.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+#include <boost/chrono/digital_time_formatter.hpp>
 #include <cmath>
 
-//#include <boost/accumulators/framework/accumulator_set.hpp>
-#include <boost/accumulators/accumulators.hpp>
-#include <boost/accumulators/statistics.hpp>
-#include <boost/accumulators/statistics/stats.hpp>
-#include <boost/accumulators/statistics/sum.hpp>
-#include <boost/accumulators/statistics/min.hpp>
-#include <boost/accumulators/statistics/max.hpp>
-#include <boost/accumulators/statistics/mean.hpp>
-#include <boost/accumulators/statistics/weighted_sum.hpp>
 
+using namespace boost::chrono;
 int f1(long j)
 {
- static boost::chrono::stopwatch_accumulator<boost::chrono::process_real_cpu_clock>::reporter t(
+ static stopwatch_accumulator<process_real_cpu_clock>::reporter t(
     "\nf1 Count=%c times Sum=%ss Min=%ms Max=%Ms Mean=%as\n");
- boost::chrono::stopwatch_accumulator<boost::chrono::process_real_cpu_clock>::reporter::scoped_run _(t);
- boost::chrono::stopwatch<boost::chrono::process_real_cpu_clock>::reporter x("\nF1 %dsec\n");
- boost::chrono::run_timer y;
-
+ stopwatch_accumulator<process_real_cpu_clock>::reporter::scoped_run _(t);
+ stopwatch<boost::chrono::process_real_cpu_clock>::reporter x("\nF1 %dsec\n");
+ run_timer y;
+ stopwatch_reporter<stopwatch<process_real_cpu_clock>, digital_time_formatter> hhmmss;
+
 
   for ( long i = 0; i < j; ++i )
     std::sqrt( 123.456L ); // burn some time
@@ -40,8 +34,8 @@
 }
 int main()
 {
- boost::chrono::stopwatch<boost::chrono::process_real_cpu_clock>::reporter _("\nMain %dsec\n");
- boost::chrono::run_timer z;
+ stopwatch<boost::chrono::process_real_cpu_clock>::reporter _("\nMain %dsec\n");
+ run_timer z;
 
 
   f1(100000);

Added: sandbox/chrono/libs/chrono/src/process_cpu_clocks.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/src/process_cpu_clocks.cpp 2010-01-13 06:05:53 EST (Wed, 13 Jan 2010)
@@ -0,0 +1,51 @@
+// boost process_cpu_clocks.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_cpu_clocks.hpp>
+#include <boost/chrono/process_times.hpp>
+#include <cassert>
+
+namespace boost { namespace chrono {
+
+ process_real_cpu_clock::time_point process_real_cpu_clock::now(system::error_code & ec) {
+ process_times t;
+ process_clock::now(t, ec);
+ return process_real_cpu_clock::time_point(t.real);
+ }
+
+ process_user_cpu_clock::time_point process_user_cpu_clock::now(system::error_code & ec){
+ process_times t;
+ process_clock::now(t, ec);
+ return process_user_cpu_clock::time_point(t.user);
+ }
+
+ process_system_cpu_clock::time_point process_system_cpu_clock::now(system::error_code & ec) {
+ process_times t;
+ process_clock::now(t, ec);
+ return process_system_cpu_clock::time_point(t.system);
+ }
+
+ process_cpu_clock::time_point process_cpu_clock::now( system::error_code & ec ) {
+ process_times t;
+ process_clock::now(t,ec);
+ time_point::rep r(t.real.count(), t.user.count(), t.system.count());
+ return time_point(duration(r));
+ }
+
+} // namespace chrono
+} // namespace boost
+
+


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