Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86655 - in branches/release: boost/chrono/detail/inlined/posix libs/chrono/test
From: vicente.botet_at_[hidden]
Date: 2013-11-12 13:30:20


Author: viboes
Date: 2013-11-12 13:30:20 EST (Tue, 12 Nov 2013)
New Revision: 86655
URL: http://svn.boost.org/trac/boost/changeset/86655

Log:
Chrono: merge fixe for #9337.

Added:
   branches/release/libs/chrono/test/test_9337.cpp
      - copied unchanged from r86547, trunk/libs/chrono/test/test_9337.cpp
Text files modified:
   branches/release/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp | 15 ++++++++-------
   branches/release/libs/chrono/test/Jamfile.v2 | 6 ++++++
   branches/release/libs/chrono/test/test_9337.cpp | 27 +++++++++++++++++++++++++++
   3 files changed, 41 insertions(+), 7 deletions(-)

Modified: branches/release/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp
==============================================================================
--- branches/release/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp Tue Nov 12 12:15:12 2013 (r86654)
+++ branches/release/boost/chrono/detail/inlined/posix/process_cpu_clocks.hpp 2013-11-12 13:30:20 EST (Tue, 12 Nov 2013) (r86655)
@@ -281,12 +281,13 @@
     }
     else
     {
- if ( chrono_detail::tick_factor() != -1 )
+ long factor = chrono_detail::tick_factor();
+ if ( factor != -1 )
         {
             time_point::rep r(
- 1000*c*chrono_detail::tick_factor(),
- 1000*(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
- 1000*(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
+ c*factor,
+ (tm.tms_utime + tm.tms_cutime)*factor,
+ (tm.tms_stime + tm.tms_cstime)*factor);
             return time_point(duration(r));
         }
         else
@@ -324,9 +325,9 @@
         if ( chrono_detail::tick_factor() != -1 )
         {
             time_point::rep r(
- 1000*c*chrono_detail::tick_factor(),
- 1000*(tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
- 1000*(tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
+ c*chrono_detail::tick_factor(),
+ (tm.tms_utime + tm.tms_cutime)*chrono_detail::tick_factor(),
+ (tm.tms_stime + tm.tms_cstime)*chrono_detail::tick_factor());
             return time_point(duration(r));
         }
         else

Modified: branches/release/libs/chrono/test/Jamfile.v2
==============================================================================
--- branches/release/libs/chrono/test/Jamfile.v2 Tue Nov 12 12:15:12 2013 (r86654)
+++ branches/release/libs/chrono/test/Jamfile.v2 2013-11-12 13:30:20 EST (Tue, 12 Nov 2013) (r86655)
@@ -481,4 +481,10 @@
         [ chrono-run win32_test.cpp ]
         ;
 
+ explicit ts_ ;
+ test-suite ts_
+ :
+ #[ chrono-run test_7868.cpp ]
+ [ chrono-run test_9337.cpp ]
+ ;
 

Copied: branches/release/libs/chrono/test/test_9337.cpp (from r86547, trunk/libs/chrono/test/test_9337.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/chrono/test/test_9337.cpp 2013-11-12 13:30:20 EST (Tue, 12 Nov 2013) (r86655, copy of r86547, trunk/libs/chrono/test/test_9337.cpp)
@@ -0,0 +1,27 @@
+//#define BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
+#include <iostream>
+#include <unistd.h>
+#include <boost/chrono.hpp>
+#include <boost/chrono/chrono_io.hpp>
+
+using namespace std;
+using namespace boost::chrono;
+
+template <typename Clock>
+void test()
+{
+ typename Clock::time_point start=Clock::now();
+ sleep(1);
+ typename Clock::time_point stop=Clock::now();
+ cout<<stop-start<<endl;
+ cout << start <<endl;
+ cout << stop <<endl;
+}
+
+int main() {
+ test<process_cpu_clock>();
+ test<process_real_cpu_clock>();
+ test<process_user_cpu_clock>();
+ test<process_system_cpu_clock>();
+ return 1;
+}


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