Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74679 - trunk/libs/chrono/example
From: vicente.botet_at_[hidden]
Date: 2011-10-03 17:12:10


Author: viboes
Date: 2011-10-03 17:12:09 EDT (Mon, 03 Oct 2011)
New Revision: 74679
URL: http://svn.boost.org/trac/boost/changeset/74679

Log:
Chrono: Add BOOST_CHRONO_HAS_PROCESS_CLOCKS protection for CE
Text files modified:
   trunk/libs/chrono/example/stopwatch_example.cpp | 12 ++++++++++--
   1 files changed, 10 insertions(+), 2 deletions(-)

Modified: trunk/libs/chrono/example/stopwatch_example.cpp
==============================================================================
--- trunk/libs/chrono/example/stopwatch_example.cpp (original)
+++ trunk/libs/chrono/example/stopwatch_example.cpp 2011-10-03 17:12:09 EDT (Mon, 03 Oct 2011)
@@ -13,6 +13,12 @@
 
 using namespace boost::chrono;
 
+#ifdef BOOST_CHRONO_HAS_PROCESS_CLOCKS
+typedef process_cpu_clock clock_type;
+#else
+typedef high_resolution_clock clock_type;
+#endif
+
 namespace ex
 {
     template<class Rep, class Period>
@@ -29,7 +35,7 @@
 
 int f1(long j)
 {
- simple_stopwatch<process_cpu_clock> sw;
+ simple_stopwatch<clock_type> sw;
 
   for ( long i = 0; i < j; ++i )
     std::sqrt( 123.456L ); // burn some time
@@ -40,13 +46,15 @@
 }
 int main()
 {
- simple_stopwatch<process_cpu_clock> sw;
+ simple_stopwatch<clock_type> sw;
 
   f1(1000);
   f1(2000);
   f1(3000);
+#ifdef BOOST_CHRONO_HAS_PROCESS_CLOCKS
   std::cout << "main() Elapsed time: " << duration_cast<duration<process_times<double>,boost::ratio<1> > >(sw.elapsed()) << std::endl;
   std::cout << "main() Elapsed time: " << duration_cast<duration<process_times<nanoseconds::rep>,boost::milli> >(sw.elapsed()) << std::endl;
+#endif
   //std::cout << "main() Elapsed time: " << sw.elapsed() << std::endl;
   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