$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r59204 - in sandbox/chrono/libs/chrono: example test
From: vicente.botet_at_[hidden]
Date: 2010-01-21 15:48:43
Author: viboes
Date: 2010-01-21 15:48:42 EST (Thu, 21 Jan 2010)
New Revision: 59204
URL: http://svn.boost.org/trac/boost/changeset/59204
Log:
Boost.Chrono: Version 0.3.2, Added examples for
* nested stopclocks
* stopwatch suspend 
Added:
   sandbox/chrono/libs/chrono/example/nested_stopclock_accumulator_example.cpp   (contents, props changed)
   sandbox/chrono/libs/chrono/example/scoped_stopwatch_example.cpp   (contents, props changed)
Text files modified: 
   sandbox/chrono/libs/chrono/test/Jamfile.v2 |     4 ++++                                    
   1 files changed, 4 insertions(+), 0 deletions(-)
Added: sandbox/chrono/libs/chrono/example/nested_stopclock_accumulator_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/example/nested_stopclock_accumulator_example.cpp	2010-01-21 15:48:42 EST (Thu, 21 Jan 2010)
@@ -0,0 +1,36 @@
+//  stopwatch_accumulator_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/stopwatches.hpp>
+#include <cmath>
+#include <boost/thread.hpp>
+
+using namespace boost::chrono;
+void f1()
+{
+    static stopclock_accumulator<> acc(stopwatch_accumulator_formatter::format(BOOST_STRINGIZE(__LINE__)));
+    stopclock_accumulator<>::scoped_run _(acc);
+    boost::this_thread::sleep(boost::posix_time::milliseconds(100));
+    {
+        static stopclock_accumulator<> acc(stopwatch_accumulator_formatter::format(BOOST_STRINGIZE(__LINE__)));
+        stopclock_accumulator<>::scoped_run _(acc);
+        boost::this_thread::sleep(boost::posix_time::milliseconds(200));
+    }
+
+}
+int main()
+{
+  static stopclock_accumulator<> acc(stopwatch_accumulator_formatter::format(BOOST_STRINGIZE(__LINE__)));
+  stopclock_accumulator<>::scoped_run _(acc);
+
+  f1();
+  f1();
+  f1();
+  return 0;
+}
Added: sandbox/chrono/libs/chrono/example/scoped_stopwatch_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/libs/chrono/example/scoped_stopwatch_example.cpp	2010-01-21 15:48:42 EST (Thu, 21 Jan 2010)
@@ -0,0 +1,36 @@
+//  stopwatch_example.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/stopwatch.hpp>
+#include <cmath>
+#include <boost/thread.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+
+using namespace boost::chrono;
+double res;
+void f1(long j)
+{   
+    stopwatch<>::reporter _(BOOST_CHRONO_STOPWATCH_FUNCTION_FORMAT);
+    for (long i =0; i< j; i+=1)
+        res+=std::sqrt( res+123.456L+i );  // burn some time
+    stopwatch<>::reporter::scoped_suspend s(_);
+    boost::this_thread::sleep(boost::posix_time::milliseconds(200));
+
+}
+int main()
+{
+  stopwatch<>::reporter _(BOOST_CHRONO_STOPWATCH_FUNCTION_FORMAT);
+
+    res=0;
+    for (long i =0; i< 3; ++i)
+        f1(i*100);
+        
+    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-21 15:48:42 EST (Thu, 21 Jan 2010)
@@ -92,8 +92,12 @@
         :
         [ run ../example/stopwatch_example.cpp :  :  : <link>static ]
         [ run ../example/stopwatch_example.cpp :  :  : <library>/boost/system//boost_system  : stopwatch_example_dll ]
+        [ run ../example/scoped_stopwatch_example.cpp :  :  : <library>/boost/thread//boost_thread <link>static ]
+        [ run ../example/scoped_stopwatch_example.cpp :  :  : <library>/boost/thread//boost_thread  <library>/boost/system//boost_system  : scoped_stopwatch_example_dll ]
         [ run ../example/stopwatch_accumulator_example.cpp :  :  : <link>static ]
         [ run ../example/stopwatch_accumulator_example.cpp :  :  : <library>/boost/system//boost_system  : stopwatch_accumulator_example_dll ]
+        [ run ../example/nested_stopclock_accumulator_example.cpp :  :  : <library>/boost/thread//boost_thread <link>static ]
+        [ run ../example/nested_stopclock_accumulator_example.cpp :  :  : <library>/boost/thread//boost_thread  <library>/boost/system//boost_system  : nested_stopclock_accumulator_example_dll ]
         [ run ../example/specific_stopwatch_accumulator_example.cpp :  :  : <link>static ]
         [ run ../example/specific_stopwatch_accumulator_example.cpp :  :  : <library>/boost/system//boost_system  : specific_stopwatch_accumulator_example_dll ]
         [ run ../example/stopclock_example.cpp :  :  : <link>static ]