|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65945 - in sandbox/chrono/boost/chrono: . detail/inlined detail/inlined/mac detail/inlined/posix detail/inlined/win
From: vicente.botet_at_[hidden]
Date: 2010-10-13 18:39:02
Author: viboes
Date: 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
New Revision: 65945
URL: http://svn.boost.org/trac/boost/changeset/65945
Log:
Chrono:
* More on making configurable header-only library
* Add clock_string<>
* Define chrono-io for all the clocks
* Add input of process_times representation
Text files modified:
sandbox/chrono/boost/chrono/chrono.hpp | 2
sandbox/chrono/boost/chrono/chrono_io.hpp | 305 ++++++++++++++++++---------------------
sandbox/chrono/boost/chrono/config.hpp | 8 +
sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp | 2
sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp | 33 ++--
sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp | 6
sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp | 2
sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp | 12
sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp | 20 +-
sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp | 6
sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp | 4
sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp | 2
sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp | 28 +-
sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp | 2
sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp | 2
sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp | 24 +-
sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp | 4
sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp | 5
sandbox/chrono/boost/chrono/process_cpu_clocks.hpp | 35 +++
sandbox/chrono/boost/chrono/process_times.hpp | 21 ++
20 files changed, 272 insertions(+), 251 deletions(-)
Modified: sandbox/chrono/boost/chrono/chrono.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/chrono.hpp (original)
+++ sandbox/chrono/boost/chrono/chrono.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -62,5 +62,7 @@
#include <boost/chrono/duration.hpp>
#include <boost/chrono/time_point.hpp>
#include <boost/chrono/system_clocks.hpp>
+#include <boost/chrono/process_cpu_clocks.hpp>
+#include <boost/chrono/thread_clock.hpp>
#endif // BOOST_CHRONO_CHRONO_HPP
Modified: sandbox/chrono/boost/chrono/chrono_io.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/chrono_io.hpp (original)
+++ sandbox/chrono/boost/chrono/chrono_io.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -13,106 +13,13 @@
#ifndef BOOST_CHRONO_CHRONO_IO_HPP
#define BOOST_CHRONO_CHRONO_IO_HPP
-/*
-
- chrono_io synopsis
-
-#include <boost/chrono.hpp>
-#include <boost/ratio/ratio_io.hpp>
-
-namespace boost
-{
-namespace chrono
-{
-
-template <class CharT>
-class duration_punct
- : public locale::facet
-{
-public:
- static locale::id id;
-
- typedef basic_string<CharT> string_type;
- enum {use_long, use_short};
-
- explicit duration_punct(int use = use_long);
-
- duration_punct(int use,
- const string_type& long_seconds, const string_type& long_minutes,
- const string_type& long_hours, const string_type& short_seconds,
- const string_type& short_minutes, const string_type& short_hours);
-
- duration_punct(int use, const duration_punct& d);
-
- template <class Period> string_type short_name() const;
- template <class Period> string_type long_name() const;
- template <class Period> string_type name() const;
-
- bool is_short_name() const;
- bool is_long_name() const;
-};
-
-struct duration_short {};
-struct duration_long {};
-
-template <class CharT, class Traits>
- basic_ostream<CharT, Traits>&
- operator<<(basic_ostream<CharT, Traits>& os, duration_short);
-
-template <class CharT, class Traits>
- basic_ostream<CharT, Traits>&
- operator<<(basic_ostream<CharT, Traits>& os, duration_long);
-
-template <class CharT, class Traits, class Rep, class Period>
- basic_ostream<CharT, Traits>&
- operator<<(basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d);
-
-template <class CharT, class Traits, class Rep, class Period>
- basic_istream<CharT, Traits>&
- operator>>(basic_istream<CharT, Traits>& is, duration<Rep, Period>& d);
-
-template <class CharT, class Traits, class Duration>
- basic_ostream<CharT, Traits>&
- operator<<(basic_ostream<CharT, Traits>& os,
- const time_point<monotonic_clock, Duration>& tp);
-
-template <class CharT, class Traits, class Duration>
- basic_ostream<CharT, Traits>&
- operator<<(basic_ostream<CharT, Traits>& os,
- const time_point<high_resolution_clock, Duration>& tp);
-
-template <class CharT, class Traits, class Duration>
- basic_ostream<CharT, Traits>&
- operator<<(basic_ostream<CharT, Traits>& os,
- const time_point<system_clock, Duration>& tp);
-
-template <class CharT, class Traits, class Duration>
- basic_istream<CharT, Traits>&
- operator>>(basic_istream<CharT, Traits>& is,
- time_point<monotonic_clock, Duration>& tp);
-
-template <class CharT, class Traits, class Duration>
- basic_istream<CharT, Traits>&
- operator>>(basic_istream<CharT, Traits>& is,
- time_point<high_resolution_clock, Duration>& tp);
-
-template <class CharT, class Traits, class Duration>
- basic_istream<CharT, Traits>&
- operator>>(basic_istream<CharT, Traits>& is,
- time_point<system_clock, Duration>& tp);
-
-} // chrono
-} // boost
-
-*/
-
-#include <boost/chrono.hpp>
+#include <boost/chrono/chrono.hpp>
#include <boost/ratio/ratio_io.hpp>
#include <locale>
#include <boost/type_traits/is_scalar.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/mpl/if.hpp>
-
+#include <boost/math/common_factor_rt.hpp>
#include <boost/chrono/detail/scan_keyword.hpp>
namespace boost
@@ -297,28 +204,7 @@
>::type type;
};
-template <class T>
-T
-gcd(T x, T y)
-{
- while (y != 0)
- {
- T old_x = x;
- x = y;
- y = old_x % y;
- }
- return x;
-}
-
-template <>
-long double
-inline
-gcd(long double , long double )
-{
- return 1;
}
-}
-
template <class CharT, class Traits, class Rep, class Period>
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, duration<Rep, Period>& d)
@@ -519,8 +405,8 @@
// unit is num/den
// r should be multiplied by (num/den) / Period
// Reduce (num/den) / Period to lowest terms
- unsigned long long gcd_n1_n2 = chrono_detail::gcd<unsigned long long>(num, Period::num);
- unsigned long long gcd_d1_d2 = chrono_detail::gcd<unsigned long long>(den, Period::den);
+ unsigned long long gcd_n1_n2 = math::gcd<unsigned long long>(num, Period::num);
+ unsigned long long gcd_d1_d2 = math::gcd<unsigned long long>(den, Period::den);
num /= gcd_n1_n2;
den /= gcd_d1_d2;
unsigned long long n2 = Period::num / gcd_n1_n2;
@@ -539,7 +425,7 @@
if (is_integral<intermediate_type>::value)
{
// Reduce r * num / den
- common_type_t t = chrono_detail::gcd<common_type_t>(r, den);
+ common_type_t t = math::gcd<common_type_t>(r, den);
r /= t;
den /= t;
if (den != 1)
@@ -582,68 +468,162 @@
return is;
}
-#ifdef BOOST_CHRONO_HAS_CLOCK_MONOTONIC
-template <class CharT, class Traits, class Duration>
-std::basic_ostream<CharT, Traits>&
-operator<<(std::basic_ostream<CharT, Traits>& os,
- const time_point<monotonic_clock, Duration>& tp)
+template <class Clock, class CharT>
+struct clock_string;
+
+template <class CharT>
+struct clock_string<system_clock, CharT>
{
- return os << tp.time_since_epoch() << " since boot";
-}
+ static std::string name()
+ {
+ static const CharT u[] = {'s', 'y', 's', 't', 'e', 'm', '_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
+ {
+ static const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'J', 'a',
+ 'n', ' ', '1', ',', ' ', '1', '9', '7', '0'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+};
+#ifdef BOOST_CHRONO_HAS_CLOCK_MONOTONIC
-template <class CharT, class Traits, class Duration>
-std::basic_istream<CharT, Traits>&
-operator>>(std::basic_istream<CharT, Traits>& is,
- time_point<monotonic_clock, Duration>& tp)
+template <class CharT>
+struct clock_string<monotonic_clock, CharT>
{
- Duration d;
- is >> d;
- if (is.good())
+ static std::string name()
+ {
+ static const CharT u[] = {'m', 'o', 'n', 'o', 't', 'o', 'n', 'i', 'c', '_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
{
const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'b', 'o', 'o', 't'};
- const std::basic_string<CharT> units(u, u + sizeof(u)/sizeof(u[0]));
- std::ios_base::iostate err = std::ios_base::goodbit;
- typedef std::istreambuf_iterator<CharT, Traits> in_iterator;
- in_iterator i(is);
- in_iterator e;
- std::ptrdiff_t k = chrono_detail::scan_keyword(i, e,
- &units, &units + 1,
- std::use_facet<std::ctype<CharT> >(is.getloc()),
- err) - &units;
- if (k == 1)
- {
- // failed to read epoch string
- is.setstate(err);
- return is;
- }
- tp = time_point<monotonic_clock, Duration>(d);
+ const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
}
- else
- is.setstate(is.failbit);
- return is;
-}
+};
+
+
+#endif
+
+#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
+
+template <class CharT>
+struct clock_string<thread_clock, CharT>
+{
+ static std::string name()
+ {
+ static const CharT u[] = {'t', 'h', 'r', 'e', 'd', '_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
+ {
+ const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 't', 'r', 'e', 'a', 'd', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'};
+ const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+};
+
#endif
-template <class CharT, class Traits, class Duration>
+template <class CharT>
+struct clock_string<process_real_cpu_clock, CharT>
+{
+ static std::string name()
+ {
+ static const CharT u[] = {'p', 'r', 'o', 'c', 'e', 's', 's', '_', 'r', 'e', 'a', 'l','_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
+ {
+ const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'};
+ const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+};
+
+template <class CharT>
+struct clock_string<process_user_cpu_clock, CharT>
+{
+ static std::string name()
+ {
+ static const CharT u[] = {'p', 'r', 'o', 'c', 'e', 's', 's', '_', 'u', 's', 'e', 'r','_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
+ {
+ const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'};
+ const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+};
+
+template <class CharT>
+struct clock_string<process_system_cpu_clock, CharT>
+{
+ static std::string name()
+ {
+ static const CharT u[] = {'p', 'r', 'o', 'c', 'e', 's', 's', '_', 's', 'y', 's', 't', 't', 'e', 'm', '_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
+ {
+ const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'};
+ const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+};
+
+template <class CharT>
+struct clock_string<process_cpu_clock, CharT>
+{
+ static std::string name()
+ {
+ static const CharT u[] = {'p', 'r', 'o', 'c', 'e', 's', 's', '_',
+ 'c', 'l','o', 'c', 'k'};
+ static const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+ static std::string since()
+ {
+ const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'p', 'r', 'o', 'c', 'e', 's', 's', ' ', 's', 't', 'a', 'r', 't', '-', 'u', 'p'};
+ const std::basic_string<CharT> str(u, u + sizeof(u)/sizeof(u[0]));
+ return str;
+ }
+};
+
+template <class CharT, class Traits, class Clock, class Duration>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os,
- const time_point<system_clock, Duration>& tp)
+ const time_point<Clock, Duration>& tp)
{
- return os << tp.time_since_epoch() << " since Jan 1, 1970";
+ return os << tp.time_since_epoch() << clock_string<Clock, CharT>::since();
}
-template <class CharT, class Traits, class Duration>
+template <class CharT, class Traits, class Clock, class Duration>
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
- time_point<system_clock, Duration>& tp)
+ time_point<Clock, Duration>& tp)
{
Duration d;
is >> d;
if (is.good())
{
- const CharT u[] = {' ', 's', 'i', 'n', 'c', 'e', ' ', 'J', 'a',
- 'n', ' ', '1', ',', ' ', '1', '9', '7', '0'};
- const std::basic_string<CharT> units(u, u + sizeof(u)/sizeof(u[0]));
+ const std::basic_string<CharT> units=clock_string<Clock, CharT>::since();
std::ios_base::iostate err = std::ios_base::goodbit;
typedef std::istreambuf_iterator<CharT, Traits> in_iterator;
in_iterator i(is);
@@ -658,13 +638,12 @@
is.setstate(err);
return is;
}
- tp = time_point<system_clock, Duration>(d);
+ tp = time_point<Clock, Duration>(d);
}
else
is.setstate(is.failbit);
return is;
}
-
} // chrono
}
Modified: sandbox/chrono/boost/chrono/config.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/config.hpp (original)
+++ sandbox/chrono/boost/chrono/config.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -60,6 +60,14 @@
# endif
# endif
+// unicode support
+
+#if defined(BOOST_NO_UNICODE_LITERALS) || defined(BOOST_NO_CHAR16_T) || defined(BOOST_NO_CHAR32_T)
+//~ #define BOOST_CHRONO_HAS_UNICODE_SUPPORT
+#else
+#define BOOST_CHRONO_HAS_UNICODE_SUPPORT 1
+#endif
+
// define constexpr related macros ------------------------------//
//~ #include <boost/config.hpp>
Modified: sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/chrono.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -8,7 +8,7 @@
// define BOOST_CHRONO_SOURCE so that <boost/filesystem/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
-#define BOOST_CHRONO_SOURCE
+//#define BOOST_CHRONO_SOURCE
#include <boost/version.hpp>
#include <boost/chrono/chrono.hpp>
Modified: sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/mac/chrono.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -24,7 +24,7 @@
// It returns the number of microseconds since New Years 1970 in a struct called timeval
// which has a field for seconds and a field for microseconds.
// Fill in the timeval and then convert that to the time_point
-BOOST_CHRONO_INLINE system_clock::time_point
+system_clock::time_point
system_clock::now()
{
timeval tv;
@@ -32,7 +32,7 @@
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
}
-BOOST_CHRONO_INLINE system_clock::time_point
+system_clock::time_point
system_clock::now(system::error_code & ec)
{
timeval tv;
@@ -44,19 +44,22 @@
// Take advantage of the fact that on this platform time_t is nothing but
// an integral count of seconds since New Years 1970 (same epoch as timeval).
// Just get the duration out of the time_point and truncate it to seconds.
-BOOST_CHRONO_INLINE time_t
+time_t
system_clock::to_time_t(const time_point& t)
{
return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
}
// Just turn the time_t into a count of seconds and construct a time_point with it.
-BOOST_CHRONO_INLINE system_clock::time_point
+system_clock::time_point
system_clock::from_time_t(time_t t)
{
return system_clock::time_point(seconds(t));
}
+namespace chrono_detail
+{
+
// monotonic_clock
// Note, in this implementation monotonic_clock and high_resolution_clock
@@ -101,7 +104,7 @@
monotonic_full()
{
static kern_return_t err;
- static const double factor = compute_monotonic_factor(err);
+ static const double factor = chrono_detail::compute_monotonic_factor(err);
if (err != 0)
boost::throw_exception(
#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
@@ -117,7 +120,7 @@
monotonic_full_ec(system::error_code & ec)
{
static kern_return_t err;
- static const double factor = compute_monotonic_factor(err);
+ static const double factor = chrono_detail::compute_monotonic_factor(err);
if (err != 0) {
#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
ec.assign( errno, system::system_category );
@@ -135,7 +138,7 @@
BOOST_CHRONO_STATIC
-FP_ec
+FP
init_monotonic_clock(kern_return_t & err)
{
mach_timebase_info_data_t MachInfo;
@@ -145,8 +148,8 @@
}
if (MachInfo.numer == MachInfo.denom)
- return &monotonic_simplified_ec;
- return &monotonic_full_ec;
+ return &chrono_detail::monotonic_simplified;
+ return &chrono_detail::monotonic_full;
}
BOOST_CHRONO_STATIC
@@ -160,16 +163,15 @@
}
if (MachInfo.numer == MachInfo.denom)
- return &monotonic_simplified_ec;
- return &monotonic_full_ec;
+ return &chrono_detail::monotonic_simplified_ec;
+ return &chrono_detail::monotonic_full_ec;
+}
}
-
-BOOST_CHRONO_INLINE
monotonic_clock::time_point
monotonic_clock::now()
{
static kern_return_t err;
- static FP fp = init_monotonic_clock(err);
+ static chrono_detail::FP_ec fp = chrono_detail::init_monotonic_clock(err);
if( err != 0 ) boost::throw_exception(
#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
system::system_error( err, system::system_category, "chrono::monotonic_clock" ));
@@ -179,12 +181,11 @@
return time_point(duration(fp()));
}
-BOOST_CHRONO_INLINE
monotonic_clock::time_point
monotonic_clock::now(system::error_code & ec)
{
static kern_return_t err;
- static FP_ec fp = init_monotonic_clock(err);
+ static chrono_detail::FP_ec fp = chrono_detail::init_monotonic_clock(err);
if( err != 0 ) {
#if ((BOOST_VERSION / 100000) < 2) && ((BOOST_VERSION / 100 % 1000) < 44)
ec.assign( err, system::system_category );
Modified: sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/mac/process_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/chrono/process_times.hpp>
@@ -23,7 +23,7 @@
namespace
{
- BOOST_CHRONO_INLINE long tick_factor() // multiplier to convert ticks
+ long tick_factor() // multiplier to convert ticks
// to nanoseconds; -1 if unknown
{
static long factor = 0;
@@ -51,7 +51,7 @@
namespace chrono
{
- BOOST_CHRONO_INLINE void process_clock::now( process_times & times_, system::error_code & ec )
+ void process_clock::now( process_times & times_, system::error_code & ec )
{
tms tm;
Modified: sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/mac/thread_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -11,7 +11,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/chrono/detail/inlined/posix/thread_clock.hpp>
Modified: sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/posix/chrono.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -18,7 +18,7 @@
namespace chrono
{
- BOOST_CHRONO_INLINE system_clock::time_point system_clock::now()
+ system_clock::time_point system_clock::now()
{
timespec ts;
if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
@@ -31,7 +31,7 @@
static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
}
- BOOST_CHRONO_INLINE system_clock::time_point system_clock::now(system::error_code & ec)
+ system_clock::time_point system_clock::now(system::error_code & ec)
{
timespec ts;
if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
@@ -45,19 +45,19 @@
static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
}
- BOOST_CHRONO_INLINE std::time_t system_clock::to_time_t(const system_clock::time_point& t)
+ std::time_t system_clock::to_time_t(const system_clock::time_point& t)
{
return static_cast<std::time_t>( t.time_since_epoch().count() / 1000000000 );
}
- BOOST_CHRONO_INLINE system_clock::time_point system_clock::from_time_t(std::time_t t)
+ system_clock::time_point system_clock::from_time_t(std::time_t t)
{
return time_point(duration(static_cast<system_clock::rep>(t) * 1000000000));
}
#ifdef BOOST_CHRONO_HAS_CLOCK_MONOTONIC
- BOOST_CHRONO_INLINE monotonic_clock::time_point monotonic_clock::now()
+ monotonic_clock::time_point monotonic_clock::now()
{
timespec ts;
if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
@@ -70,7 +70,7 @@
static_cast<monotonic_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
}
- BOOST_CHRONO_INLINE monotonic_clock::time_point monotonic_clock::now(system::error_code & ec)
+ monotonic_clock::time_point monotonic_clock::now(system::error_code & ec)
{
timespec ts;
if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
Modified: sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/posix/process_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/chrono/process_times.hpp>
@@ -21,9 +21,11 @@
# include <sys/times.h>
# include <unistd.h>
-namespace
+
+namespace boost { namespace chrono {
+namespace chrono_detail
{
- BOOST_CHRONO_INLINE long tick_factor() // multiplier to convert ticks
+ long tick_factor() // multiplier to convert ticks
// to nanoseconds; -1 if unknown
{
static long factor = 0;
@@ -42,9 +44,7 @@
}
}
-namespace boost { namespace chrono {
-
- BOOST_CHRONO_INLINE void process_clock::now( process_times & times_, system::error_code & ec ) {
+ void process_clock::now( process_times & times_, system::error_code & ec ) {
tms tm;
clock_t c = ::times( &tm );
@@ -63,11 +63,11 @@
times_.real = microseconds(c);
times_.system = microseconds(tm.tms_stime + tm.tms_cstime);
times_.user = microseconds(tm.tms_utime + tm.tms_cutime);
- if ( tick_factor() != -1 )
+ if ( chrono_detail::tick_factor() != -1 )
{
- times_.real *= tick_factor();
- times_.user *= tick_factor();
- times_.system *= tick_factor();
+ times_.real *= chrono_detail::tick_factor();
+ times_.user *= chrono_detail::tick_factor();
+ times_.system *= chrono_detail::tick_factor();
}
else
{
Modified: sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/posix/thread_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/chrono/thread_clock.hpp>
@@ -23,7 +23,7 @@
namespace boost { namespace chrono {
- BOOST_CHRONO_INLINE thread_clock::time_point thread_clock::now( ) {
+ thread_clock::time_point thread_clock::now( ) {
// get the current thread
pthread_t pth=pthread_self();
// get the clock_id associated to the current thread
@@ -46,7 +46,7 @@
static_cast<thread_clock::rep>( ts.tv_sec ) * 1000000000 + ts.tv_nsec));
}
- BOOST_CHRONO_INLINE thread_clock::time_point thread_clock::now( system::error_code & ec ) {
+ thread_clock::time_point thread_clock::now( system::error_code & ec ) {
// get the current thread
pthread_t pth=pthread_self();
// get the clock_id associated to the current thread
Modified: sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/process_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/version.hpp>
@@ -46,8 +46,6 @@
tps.real=process_clock::time_point(t.real);
tps.user=process_clock::time_point(t.user);
tps.system=process_clock::time_point(t.system);
-
}
-
}}
Modified: sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/process_cpu_clocks.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -11,7 +11,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/version.hpp>
Modified: sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/run_timer.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/version.hpp>
#include <boost/chrono/process_times.hpp>
@@ -21,10 +21,12 @@
#include <cstring>
#include <cassert>
-using boost::chrono::nanoseconds;
-using boost::chrono::duration;
-namespace
+namespace boost
+{
+namespace chrono
+{
+namespace chrono_detail
{
const char * default_format =
"\nreal %rs, cpu %cs (%p%), user %us, system %ss\n";
@@ -86,13 +88,9 @@
}
}
-} // unnamed namespace
+}
-namespace boost
-{
- namespace chrono
- {
-
+
run_timer::run_timer( system::error_code & ec )
: m_places(m_default_places), m_os(m_cout()) { start(ec); }
@@ -133,7 +131,7 @@
void run_timer::report( system::error_code & ec )
{
m_reported = true;
- if ( m_format.empty() ) m_format = default_format;
+ if ( m_format.empty() ) m_format = chrono_detail::default_format;
process_times times;
elapsed( times, ec );
@@ -141,13 +139,13 @@
if ( &ec == &system::throws )
{
- show_time( times, m_format.c_str(), m_places, m_os );
+ chrono_detail::show_time( times, m_format.c_str(), m_places, m_os );
}
else // non-throwing
{
try
{
- show_time( times, m_format.c_str(), m_places, m_os );
+ chrono_detail::show_time( times, m_format.c_str(), m_places, m_os );
ec.clear();
}
@@ -168,14 +166,14 @@
void run_timer::test_report( duration real_, duration user_, duration system_ )
{
- if ( m_format.empty() ) m_format = default_format;
+ if ( m_format.empty() ) m_format = chrono_detail::default_format;
process_times times;
times.real = real_;
times.user = user_;
times.system = system_;
- show_time( times, m_format.c_str(), m_places, m_os );
+ chrono_detail::show_time( times, m_format.c_str(), m_places, m_os );
}
} // namespace chrono
Modified: sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/run_timer_static.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -19,7 +19,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/version.hpp>
#include <boost/chrono/process_times.hpp>
Modified: sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/thread_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/version.hpp>
Modified: sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/win/chrono.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -11,9 +11,15 @@
#include <windows.h>
-namespace
+
+namespace boost
+{
+namespace chrono
+{
+
+namespace chrono_detail
{
- BOOST_CHRONO_INLINE
+
double get_nanosecs_per_tic()
{
LARGE_INTEGER freq;
@@ -22,17 +28,11 @@
return double(1000000000.0L / freq.QuadPart);
}
- const double nanosecs_per_tic = get_nanosecs_per_tic();
}
-
-namespace boost
-{
-namespace chrono
-{
-
- BOOST_CHRONO_INLINE
+
monotonic_clock::time_point monotonic_clock::now()
{
+ static double nanosecs_per_tic = chrono_detail::get_nanosecs_per_tic();
LARGE_INTEGER pcount;
if ( (nanosecs_per_tic <= 0.0L) || (!QueryPerformanceCounter( &pcount )) )
@@ -50,10 +50,10 @@
static_cast<monotonic_clock::rep>((nanosecs_per_tic) * pcount.QuadPart) ));
}
- BOOST_CHRONO_INLINE
+
monotonic_clock::time_point monotonic_clock::now( system::error_code & ec )
{
- static double nanosecs_per_tic = get_nanosecs_per_tic();
+ static double nanosecs_per_tic = chrono_detail::get_nanosecs_per_tic();
LARGE_INTEGER pcount;
if ( (nanosecs_per_tic <= 0.0L) || (!QueryPerformanceCounter( &pcount )) )
Modified: sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/win/process_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -12,7 +12,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/chrono/process_times.hpp>
@@ -25,7 +25,7 @@
namespace chrono
{
- BOOST_CHRONO_INLINE
+
void process_clock::now( process_times & times_, system::error_code & ec )
{
Modified: sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp (original)
+++ sandbox/chrono/boost/chrono/detail/inlined/win/thread_clock.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -11,7 +11,7 @@
// 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
+//#define BOOST_CHRONO_SOURCE
#include <boost/chrono/config.hpp>
#include <boost/chrono/thread_clock.hpp>
@@ -24,7 +24,6 @@
namespace chrono
{
- BOOST_CHRONO_INLINE
thread_clock::time_point thread_clock::now( system::error_code & ec )
{
@@ -59,8 +58,6 @@
}
-
- BOOST_CHRONO_INLINE
thread_clock::time_point thread_clock::now( )
{
Modified: sandbox/chrono/boost/chrono/process_cpu_clocks.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/process_cpu_clocks.hpp (original)
+++ sandbox/chrono/boost/chrono/process_cpu_clocks.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -15,6 +15,7 @@
#include <boost/system/error_code.hpp>
#include <boost/operators.hpp>
#include <boost/chrono/detail/system.hpp>
+#include <iostream>
#ifndef BOOST_CHRONO_INLINED
@@ -125,10 +126,28 @@
if (system < rhs.system) return true;
else return false;
}
+
+ template <class CharT, class Traits>
+ void print(std::basic_ostream<CharT, Traits>& os) const {
+ os << "{"<< real <<";"<< user <<";"<< system << "}";
+ }
- template <typename OSTREAM>
- void print(OSTREAM& os) const {
- os << "{"<< real <<","<< user <<","<< system << "}";
+ template <class CharT, class Traits>
+ void read(std::basic_istream<CharT, Traits>& is) const {
+ typedef std::istreambuf_iterator<CharT, Traits> in_iterator;
+ in_iterator i(is);
+ in_iterator e;
+ if (i == e || *i != '{') // mandatory '{'
+ {
+ is.setstate(is.failbit | is.eofbit);
+ return;
+ }
+ CharT x,y,z;
+ is >> real >> x >> user >> y >> system >> z;
+ if (!is.good() || (x != ';')|| (y != ';')|| (z != '}'))
+ {
+ is.setstate(is.failbit);
+ }
}
};
@@ -146,12 +165,18 @@
static BOOST_CHRONO_INLINE time_point now( system::error_code & ec = system::throws );
};
- template <typename OSTREAM>
- OSTREAM& operator<<(OSTREAM& os, process_cpu_clock_times const& rhs) {
+ template <class CharT, class Traits>
+ std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, process_cpu_clock_times const& rhs) {
rhs.print(os);
return os;
}
+ template <class CharT, class Traits>
+ std::basic_istream<CharT, Traits>& operator<<(std::basic_istream<CharT, Traits>& is, process_cpu_clock_times const& rhs) {
+ rhs.read(is);
+ return is;
+ }
+
template <>
struct duration_values<process_cpu_clock_times>
{
Modified: sandbox/chrono/boost/chrono/process_times.hpp
==============================================================================
--- sandbox/chrono/boost/chrono/process_times.hpp (original)
+++ sandbox/chrono/boost/chrono/process_times.hpp 2010-10-13 18:38:56 EDT (Wed, 13 Oct 2010)
@@ -11,7 +11,8 @@
#ifndef BOOST_PROCESS_TIMES_HPP
#define BOOST_PROCESS_TIMES_HPP
-#include <boost/chrono/chrono.hpp>
+#include <boost/chrono/duration.hpp>
+#include <boost/chrono/time_point.hpp>
#include <boost/system/error_code.hpp>
#include <boost/cstdint.hpp>
#include <string>
@@ -121,27 +122,37 @@
// std::cout, which in turn would require including <iostream>, with its
// high associated cost, even when the standard streams are not used.
+ BOOST_CHRONO_INLINE
explicit run_timer( system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
explicit run_timer( std::ostream & os,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
explicit run_timer( const std::string & format,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
run_timer( std::ostream & os, const std::string & format,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
run_timer( const std::string & format, int places,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
run_timer( std::ostream & os, const std::string & format,
int places, system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
explicit run_timer( int places,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
run_timer( std::ostream & os, int places,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
run_timer( int places, const std::string & format,
system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE
run_timer( std::ostream & os, int places, const std::string & format,
system::error_code & ec = system::throws );
@@ -157,9 +168,9 @@
process_timer::start( ec );
}
- void report( system::error_code & ec = system::throws );
+ BOOST_CHRONO_INLINE void report( system::error_code & ec = system::throws );
- void test_report( duration real_, duration user_, duration system_ );
+ BOOST_CHRONO_INLINE void test_report( duration real_, duration user_, duration system_ );
bool reported() const { return m_reported; }
@@ -179,7 +190,7 @@
#endif
bool m_reported;
- static std::ostream & m_cout();
+ BOOST_CHRONO_INLINE static std::ostream & m_cout();
static const int m_default_places = 3;
run_timer(const run_timer&); // = delete;
run_timer& operator=(const run_timer&); // = delete;
@@ -192,6 +203,8 @@
#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
#else
#include <boost/chrono/detail/inlined/process_clock.hpp>
+#include <boost/chrono/detail/inlined/run_timer.hpp>
+#include <boost/chrono/detail/inlined/run_timer_static.hpp>
#endif
#endif // BOOST_PROCESS_TIMES_HPP
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