|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74804 - in branches/release/libs/chrono: doc perf
From: vicente.botet_at_[hidden]
Date: 2011-10-08 10:24:54
Author: viboes
Date: 2011-10-08 10:24:53 EDT (Sat, 08 Oct 2011)
New Revision: 74804
URL: http://svn.boost.org/trac/boost/changeset/74804
Log:
Chrono: Added perf now()
Added:
branches/release/libs/chrono/perf/
branches/release/libs/chrono/perf/Jamfile.v2 (contents, props changed)
branches/release/libs/chrono/perf/store_now_in_vector.cpp (contents, props changed)
Text files modified:
branches/release/libs/chrono/doc/chrono.qbk | 205 ++++++++++++++-------------------------
1 files changed, 76 insertions(+), 129 deletions(-)
Modified: branches/release/libs/chrono/doc/chrono.qbk
==============================================================================
--- branches/release/libs/chrono/doc/chrono.qbk (original)
+++ branches/release/libs/chrono/doc/chrono.qbk 2011-10-08 10:24:53 EDT (Sat, 08 Oct 2011)
@@ -102,7 +102,7 @@
[template chrono_conf[link_text] [link chrono.reference.cpp0x.chrono_chrono_hpp.conf [link_text]]]
-[def __BOOST_CHRONO_HEADER_ONLY [link chrono.reference.cpp0x.chrono_hpp.conf.header_only `BOOST_CHRONO_HEADER_ONLY`]]
+[def __BOOST_CHRONO_HEADER_ONLY [link chrono.reference.cpp0x.chrono_chrono_hpp.conf.header_only `BOOST_CHRONO_HEADER_ONLY`]]
[def __BOOST_SYSTEM_INLINED `BOOST_SYSTEM_INLINED`]
[def __BOOST_CHRONO_USES_STATIC_ASSERT [chrono_conf `BOOST_CHRONO_USES_STATIC_ASSERT`]]
@@ -2363,6 +2363,22 @@
The documentation doesn't use these macros.
+[/=============================================]
+[section:chrono_include_hpp Header `<boost/chrono/include.hpp>`]
+[/=============================================]
+
+Include all the chrono header files.
+
+ #include <boost/chrono/chrono.hpp>
+ #include <boost/chrono/chrono_io.hpp>
+ #include <boost/chrono/process_cpu_clocks.hpp>
+ #include <boost/chrono/thread_clocks.hpp>
+ #include <boost/chrono/ceil.hpp>
+ #include <boost/chrono/floor.hpp>
+ #include <boost/chrono/round.hpp>
+
+[endsect]
+
[section:cpp0x Included on the C++11 Recommendation]
@@ -2370,6 +2386,18 @@
[section:chrono_hpp Header `<boost/chrono.hpp>`]
[/=============================================]
+Include only the standard files.
+
+ #include <boost/chrono/chrono.hpp>
+
+[endsect]
+
+[/=============================================]
+[section:chrono_chrono_hpp Header `<boost/chrono.hpp>`]
+[/=============================================]
+
+Include only the standard files.
+
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/chrono/system_clocks.hpp>
@@ -2414,12 +2442,24 @@
[endsect]
+[section:no_hybrid Don't provide Hybrid Error Handling]
+
+When `BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING` is defined the lib don't provides the hybrid error handling prototypes:
+
+ Clock::time_point Clock::now(system::error_code&ec=boost::thows());
+
+This allow to be closer to the standard and to avoid the Boost.System dependency, making possible to have Boost.Chrono as a header-only library.
+
+[endsect] [/section:header_only How to Build Boost.Chrono as a Header Only Library?]
+
[section:header_only How to Build Boost.Chrono as a Header Only Library?]
When `BOOST_CHRONO_HEADER_ONLY` is defined the lib is header-only.
If in addition `BOOST_USE_WINDOWS_H` is defined `<windows.h>` is included, otherwise files in `boost/detail/win` are used to reduce the impact of including `<windows.h>`.
+However, you will either need to define `BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING` or link with Boost.System.
+
[endsect] [/section:header_only How to Build Boost.Chrono as a Header Only Library?]
[endsect] [/section:conf Configuration Macros]
@@ -3716,6 +3756,38 @@
[endsect]
+[/==================================================================]
+[section:clock_strings_hpp Header `<boost/chrono/clock_strings.hpp>`]
+[/==================================================================]
+
+ namespace boost {
+ namespace chrono {
+
+ template <class __Clock, class CharT>
+ struct clock_string;
+
+ }
+ }
+
+[section:clock_string Template Class `clock_string<>`]
+
+ template <class __Clock, class CharT>
+ struct clock_string;
+
+This template must be specialized for specific clocks. The specialization must define the following functions
+
+ static std::basic_string<CharT> name();
+ static std::basic_string<CharT> since();
+
+`clock_string<>::name()` return the clock name, which usually corresponds to the class name.
+
+`clock_string<>::since()` return the textual format of the clock epoch.
+
+
+[endsect]
+
+[endsect] [/section:clock_strings_hpp Header `<boost/chrono/clock_strings.hpp>`]
+
[/=============================================]
[section:chrono_typeof_hpp Header `<boost/chrono/typeof/boost/chrono/chrono.hpp>`]
[/=============================================]
@@ -3740,9 +3812,6 @@
template <class CharT>
class duration_punct;
- template <class Clock, class CharT>
- struct clock_string;
-
template <class CharT, class Traits>
std::basic_ostream<CharT, Traits>&
duration_short(std::basic_ostream<CharT, Traits>& os);
@@ -3805,130 +3874,6 @@
[endsect]
-[section:clock_string Template Class `clock_string<>`]
-
- template <class Clock, class CharT>
- struct clock_string;
-
-This template must be specialized for specific clocks. The specialization must define the following functions
-
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
-
-`clock_string<>::name()` return the clock name, which usually corresponds to the class name.
-`clock_string<>::since()` return the textual format of the clock epoch.
-
-
-[endsect]
-
-[section:clock_string_system_clock `clock_string<system_clock>` Specialization]
-
- template <class CharT>
- struct clock_string<system_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
-
-`clock_string<>::name()` returns "system_clock".
-`clock_string<>::since()` returns " since Jan 1, 1970"
-
-
-[endsect]
-
-[section:clock_string_steady_clock `clock_string<steady_clock>` Specialization]
-
- #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
-
- template <class CharT>
- struct clock_string<steady_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
- #endif
-
-`clock_string<>::name()` returns "steady_clock".
-`clock_string<>::since()` returns " since boot"
-
-[endsect]
-
-[section:clock_string_thread_clock `clock_string<thread_clock>` Specialization]
-
- #if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
- template <class CharT>
- struct clock_string<thread_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
- #endif
-
-`clock_string<>::name()` returns "thread_clock".
-`clock_string<>::since()` returns " since thread start-up"
-
-
-[endsect]
-
-[section:clock_string_process_real_cpu_clock `clock_string<process_real_cpu_clock>` Specialization]
-
- template <class CharT>
- struct clock_string<process_real_cpu_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
-
-`clock_string<>::name()` returns "process_real_cpu_clock".
-`clock_string<>::since()` returns " since process start-up"
-
-[endsect]
-
-[section:clock_string_process_user_cpu_clock `clock_string<process_user_cpu_clock>` Specialization]
-
- template <class CharT>
- struct clock_string<process_user_cpu_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
-
-`clock_string<>::name()` returns "process_user_cpu_clock".
-`clock_string<>::since()` returns " since process start-up"
-
-
-[endsect]
-
-[section:clock_string_process_system_cpu_clock `clock_string<process_system_cpu_clock>` Specialization]
-
- template <class CharT>
- struct clock_string<process_system_cpu_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
-
-`clock_string<>::name()` returns "process_system_cpu_clock".
-`clock_string<>::since()` returns " since process start-up"
-
-
-[endsect]
-
-[section:clock_string_process_cpu_clock `clock_string<process_cpu_clock>` Specialization]
-
- template <class CharT>
- struct clock_string<process_cpu_clock, CharT>
- {
- static std::basic_string<CharT> name();
- static std::basic_string<CharT> since();
- };
-
-`clock_string<>::name()` returns "process_cpu_clock".
-`clock_string<>::since()` returns " since process start-up"
-
-
-[endsect]
-
[section:manipulators I/O Manipulators]
The short or long format can be easily chosen by streaming a `duration_short` or `duration_long` manipulator respectively.
@@ -4931,8 +4876,10 @@
[*New Features:]
-* [@http://svn.boost.org/trac/boost/ticket/5979 #5979] Added chrono rounding utilities as defined By Howard Hinnant [@http://home.roadrunner.com/~hinnant/duration_io/chrono_util.html here].
+* [@http://svn.boost.org/trac/boost/ticket/5979 #5979] Added chrono rounding utilities as defined By Howard Hinnant [@http://home.roadrunner.com/~hinnant/duration_io/chrono_util.html here].
* [@http://svn.boost.org/trac/boost/ticket/5978 #5978] Add BOOST_CHRONO_HAS_PROCESS_CLOCKS to know if process clocks are available.
+* [@http://svn.boost.org/trac/boost/ticket/5998 #5998] Make possible to don't provide hybrid error handling.
+
* [@http://svn.boost.org/trac/boost/ticket/5906 #5906] Take in account the constexpr as defined in the standard.
* [@http://svn.boost.org/trac/boost/ticket/5907 #5907] Take in account noexcept for compilers supporting it.
Added: branches/release/libs/chrono/perf/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/release/libs/chrono/perf/Jamfile.v2 2011-10-08 10:24:53 EDT (Sat, 08 Oct 2011)
@@ -0,0 +1,168 @@
+# Boost Chrono Library test Jamfile
+
+# Copyright Beman Dawes 2008
+# Copyright Vicente J. Botet Escriba 2009-2010
+
+# 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/chrono
+
+import os ;
+import feature ;
+
+project
+ : requirements
+ <target-os>freebsd:<threading>multi
+ <target-os>linux:<threading>multi
+ <toolset>pgi:<threading>multi
+ <toolset>msvc:<asynch-exceptions>on
+ <define>BOOST_CHRONO_USES_MPL_ASSERT
+ <define>BOOST_SYSTEM_NO_DEPRECATED
+ <toolset>sun:<define>BOOST_TYPEOF_EMULATION
+ <warnings>all
+ <toolset>gcc:<cxxflags>-Wextra
+ <toolset>gcc:<cxxflags>-pedantic
+ <toolset>gcc:<cxxflags>-Wno-long-long
+ <toolset>darwin:<cxxflags>-Wextra
+ <toolset>darwin:<cxxflags>-pedantic
+ <toolset>darwin:<cxxflags>-Wno-long-long
+ #<toolset>pathscale:<cxxflags>-Wextra
+ <toolset>pathscale:<cxxflags>-Wno-long-long
+ <toolset>pathscale:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wextra
+ <toolset>clang:<cxxflags>-pedantic
+ <toolset>clang:<cxxflags>-Wno-long-long
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-Wno-missing-field-initializers
+ <toolset>gcc-mingw-4.5.0:<cxxflags>-fdiagnostics-show-option
+ <toolset>msvc:<cxxflags>/wd4127
+# Note: Some of the remarks from the Intel compiler are disabled
+# remark #304: access control not specified ("public" by default)
+# remark #383: value copied to temporary, reference to temporary used
+# remark #1418: external function definition with no prior declaration
+ <toolset>intel:<cxxflags>-wd304,383,1418
+ ;
+
+rule chrono-run ( sources )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_header ]
+ ;
+}
+rule chrono-run2 ( sources : name )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(name)_header ]
+ ;
+}
+
+
+rule chrono-run-mt ( sources )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(sources[1]:B)_header ]
+ ;
+}
+rule chrono-run2-mt ( sources : name )
+{
+ return
+ [ run $(sources) ../build//boost_chrono
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_shared ]
+ [ run $(sources) ../build//boost_chrono/<link>static
+ : :
+ :
+ <library>/boost/system//boost_system
+ : $(name)_static ]
+ [ run $(sources)
+ : :
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment one of the following lines
+ #<define>BOOST_SYSTEM_INLINED
+ <library>/boost/system//boost_system
+ : $(name)_header ]
+ ;
+}
+rule chrono-compile ( sources )
+{
+ return
+ [ compile $(sources)
+ :
+ : $(sources[1]:B)_lib ]
+ [ compile $(sources)
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment the following line
+ <define>BOOST_SYSTEM_INLINED
+ : $(sources[1]:B)_header ]
+ ;
+}
+
+rule chrono-compile2 ( sources : name )
+{
+ return
+ [ compile $(sources)
+ :
+ : $(name)_lib ]
+ [ compile $(sources)
+ : <define>BOOST_CHRONO_HEADER_ONLY
+ # comment the following line
+ <define>BOOST_SYSTEM_INLINED
+ : $(name)_header ]
+ ;
+}
+
+ test-suite "perf"
+ :
+ [ chrono-run store_now_in_vector.cpp ]
+ ;
+
Added: branches/release/libs/chrono/perf/store_now_in_vector.cpp
==============================================================================
--- (empty file)
+++ branches/release/libs/chrono/perf/store_now_in_vector.cpp 2011-10-08 10:24:53 EDT (Sat, 08 Oct 2011)
@@ -0,0 +1,149 @@
+// Copyright 2011 Vicente J. Botet Escriba
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+#include <boost/chrono/chrono.hpp>
+#include <boost/chrono/chrono_io.hpp>
+#include <libs/chrono/example/timer.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+#include <vector>
+
+//#define BOOST_CHRONO_HAS_TIMES_AND_CLOCK
+
+#ifdef BOOST_CHRONO_HAS_TIMES_AND_CLOCK
+#include <sys/time.h> //for gettimeofday and timeval
+#include <sys/times.h> //for times
+#include <unistd.h>
+#endif
+
+
+static const std::size_t size = 1000000;
+
+typedef boost::chrono::timer<boost::chrono::high_resolution_clock> Stopwatch;
+
+template <typename Clock>
+void perf_constant(std::vector<typename Clock::time_point>& vec)
+{
+ for (int i=size-1; i>=0; --i)
+ {
+ vec[i]=typename Clock::time_point();
+ }
+}
+
+template <typename Clock>
+void perf(std::vector<typename Clock::time_point>& vec)
+{
+ for (int i=size-1; i>=0; --i)
+ {
+ vec[i]=Clock::now();
+ }
+}
+
+template <typename Clock>
+void test()
+{
+ std::vector<typename Clock::time_point> vec(size);
+ Stopwatch sw1;
+ perf_constant<Clock>(vec);
+ Stopwatch::duration t1 = sw1.elapsed();
+ Stopwatch sw2;
+ perf<Clock>(vec);
+ Stopwatch::duration t2 = sw2.elapsed();
+ std::cout <<" "<< (t2-t1) << std::endl;
+ //std::cout <<" "<< ((t2-t1)/size) << std::endl;
+ std::size_t cnt=0;
+ for (int i=size-1; i>0; --i)
+ {
+ if (vec[i]!=vec[i-1]) ++cnt;
+ }
+ std::cout <<"changes: "<< cnt << std::endl;
+
+}
+
+
+
+
+
+#ifdef BOOST_CHRONO_HAS_TIMES_AND_CLOCK
+void perf2(std::vector<clock_t>& vec)
+{
+ Stopwatch sw;
+ for (int i=size-1; i>=0; --i)
+ {
+ tms tm;
+ vec[i]=::times(&tm);
+ }
+ std::cout << sw.elapsed() << std::endl;
+}
+
+void perf3(std::vector<clock_t>& vec)
+{
+ Stopwatch sw;
+ for (int i=size-1; i>=0; --i)
+ {
+ vec[i]=::clock();
+ }
+ std::cout << sw.elapsed() << std::endl;
+}
+
+void test2()
+{
+ std::vector<clock_t> vec(size);
+ perf2(vec);
+ std::size_t cnt=0;
+ for (int i=10; i>0; --i)
+ {
+ if (vec[i]!=vec[i-1]) ++cnt;
+ std::cout << vec[i] << " " ;
+ }
+ std::cout<< std::endl;
+ std::cout <<"changes: "<< cnt << std::endl;
+}
+
+void test3()
+{
+ std::vector<clock_t> vec(size);
+ perf3(vec);
+ std::size_t cnt=0;
+ for (int i=10; i>0; --i)
+ {
+ if (vec[i]!=vec[i-1]) ++cnt;
+ std::cout << vec[i] << " " ;
+ }
+ std::cout<< std::endl;
+ std::cout <<"changes: "<< cnt << std::endl;
+}
+
+#endif
+
+int main() {
+
+ std::cout << "system_clock ";
+ test<boost::chrono::system_clock>();
+#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
+ std::cout << "steady_clock " ;
+ test<boost::chrono::steady_clock>();
+#endif
+ std::cout << "high_resolution_clock " ;
+ test<boost::chrono::high_resolution_clock>();
+
+#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
+ std::cout << "process_real_cpu_clock ";
+ test<boost::chrono::process_real_cpu_clock>();
+ std::cout << "process_user_cpu_clock ";
+ test<boost::chrono::process_user_cpu_clock>();
+ std::cout << "process_system_cpu_clock " ;
+ test<boost::chrono::process_system_cpu_clock>();
+ std::cout << "process_cpu_clock " ;
+ test<boost::chrono::process_cpu_clock>();
+#endif
+
+#ifdef BOOST_CHRONO_HAS_TIMES_AND_CLOCK
+ std::cout << "times ";
+ test2();
+ std::cout << "clock ";
+ test3();
+#endif
+ 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