diff options
author | Daniil Cherednik <dan.cherednik@gmail.com> | 2022-09-21 20:17:38 +0300 |
---|---|---|
committer | Daniil Cherednik <dan.cherednik@gmail.com> | 2022-09-21 20:17:38 +0300 |
commit | e6c9b17192c56494adba359d5e132c431b241191 (patch) | |
tree | 6f2449871a118a0e8919ce842b1174e06cb470ef /contrib/restricted/boost/libs/chrono | |
parent | 285021ab1aac39e84b269d9bacd4deee69cf63fc (diff) | |
download | ydb-e6c9b17192c56494adba359d5e132c431b241191.tar.gz |
Ydb stable 22-4-2122.4.21
x-stable-origin-commit: e89099581237299a132feafb5b58af59ebd0468a
Diffstat (limited to 'contrib/restricted/boost/libs/chrono')
29 files changed, 3336 insertions, 1 deletions
diff --git a/contrib/restricted/boost/libs/chrono/.yandex_meta/licenses.list.txt b/contrib/restricted/boost/libs/chrono/.yandex_meta/licenses.list.txt new file mode 100644 index 0000000000..261729da1d --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/.yandex_meta/licenses.list.txt @@ -0,0 +1,86 @@ +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== +// Distributed under the Boost +// Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) + + +====================COPYRIGHT==================== +// (C) Copyright Howard Hinnant +// Copyright 2011 Vicente J. Botet Escriba + + +====================COPYRIGHT==================== +// Copyright 2009-2010 Vicente J. Botet Escriba + + +====================COPYRIGHT==================== +// Copyright 2009-2011 Vicente J. Botet Escriba + + +====================COPYRIGHT==================== +// Copyright 2010 Vicente J. Botet Escriba + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 2003, 2006, 2008 +// Copyright 2009-2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 2008 +// Copyright Vicente J. Botet Escriba 2009 + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 2008 +// Copyright Vicente J. Botet Escriba 2009-2010 + + +====================COPYRIGHT==================== +// (C) Copyright Vicente J. Botet Escriba 2010. +// Distributed under the Boost +// Software License, Version 1.0. + + +====================File: LICENSE_1_0.txt==================== +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/contrib/restricted/boost/libs/chrono/CMakeLists.txt b/contrib/restricted/boost/libs/chrono/CMakeLists.txt index fc7b1ee73c..dbfe6fa2c4 100644 --- a/contrib/restricted/boost/libs/chrono/CMakeLists.txt +++ b/contrib/restricted/boost/libs/chrono/CMakeLists.txt @@ -8,6 +8,6 @@ if (APPLE) include(CMakeLists.darwin.txt) -elseif (UNIX AND NOT APPLE) +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND UNIX AND NOT APPLE) include(CMakeLists.linux.txt) endif() diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches.hpp new file mode 100644 index 0000000000..66fd02cb17 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches.hpp @@ -0,0 +1,24 @@ +////////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Vicente J. Botet Escriba 2010. +// Distributed under the Boost +// Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/stm for documentation. +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_STOPWATCHES_HPP +#define BOOST_STOPWATCHES_HPP + +//----------------------------------------------------------------------------- +#include <boost/chrono/stopwatches/simple_stopwatch.hpp> +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp> +#include <boost/chrono/stopwatches/reporters/system_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/process_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/thread_default_formatter.hpp> +//----------------------------------------------------------------------------- + +#endif // BOOST_STOPWATCHES_HPP diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp new file mode 100644 index 0000000000..740c40d28c --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp @@ -0,0 +1,66 @@ +// boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_MEMORIES_LAPS_ACCUMULATOR_SET_HPP +#define BOOST_CHRONO_STOPWATCHES_MEMORIES_LAPS_ACCUMULATOR_SET_HPP + +#include <boost/chrono/stopwatches/collectors/last_lap.hpp> +#include <boost/accumulators/framework/accumulator_set.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/min.hpp> +#include <boost/accumulators/statistics/max.hpp> +#include <boost/accumulators/statistics/mean.hpp> +#include <boost/accumulators/accumulators.hpp> +#include <boost/accumulators/framework/features.hpp> + +namespace boost +{ + namespace chrono + { + + template< + typename Duration, + typename Features = accumulators::features<accumulators::tag::count, + accumulators::tag::sum, accumulators::tag::min, + accumulators::tag::max, accumulators::tag::mean>, + typename Weight = void> + struct laps_accumulator_set : last_lap<Duration> + { + typedef last_lap<Duration> base_type; + typedef Duration duration; + typedef typename duration::rep rep; + typedef accumulators::accumulator_set<rep, Features, + Weight> storage_type; + storage_type acc_; + + void store(duration const& d) + { + this->base_type::store(d); + acc_(d.count()); + } + + void reset() + { + this->base_type::reset(); + acc_ = storage_type(); + } + + storage_type const& accumulator_set() const { return acc_; } + + duration elapsed() const { return duration(accumulators::sum(acc_)); } + + }; + + + } // namespace chrono +} // namespace boost + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_sequence_container.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_sequence_container.hpp new file mode 100644 index 0000000000..debb5fc102 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_sequence_container.hpp @@ -0,0 +1,65 @@ +// boost/chrono/stopwatches/collectors/laps_sequence_container.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_MEMORIES_LAPS_CONTAINER_HPP +#define BOOST_CHRONO_STOPWATCHES_MEMORIES_LAPS_CONTAINER_HPP + +#include <list> + +namespace boost +{ + namespace chrono + { + + template< + typename Duration, + typename SequenceContainer = std::list<Duration> + > + struct laps_sequence_container + { + typedef Duration duration; + typedef typename duration::rep rep; + typedef SequenceContainer storage_type; + typedef typename SequenceContainer::iterator iterator; + typedef typename SequenceContainer::const_iterator const_iterator; + storage_type cont_; + + void store(duration const& d) + { + cont_.push_front(d); + } + + void reset() + { + cont_.clear(); + } + + storage_type const& container() const { return cont_; } + + duration last() const { + if (cont_.empty()) + return duration::zero(); + else + return *cont_.begin(); + } + + duration elapsed() const { + duration elapsed_ = duration::zero(); + for (const_iterator it = cont_.begin(); it !=cont_.end(); ++it) elapsed_ += *it; + return elapsed_; + } + + }; + + + } // namespace chrono +} // namespace boost + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/last_lap.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/last_lap.hpp new file mode 100644 index 0000000000..1a24392f4b --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/last_lap.hpp @@ -0,0 +1,42 @@ +// boost/chrono/stopwatches/collectors/last_lap.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_MEMORIES_LAST_LAP_HPP +#define BOOST_CHRONO_STOPWATCHES_MEMORIES_LAST_LAP_HPP + + +namespace boost +{ + namespace chrono + { + + template<typename Duration> + struct last_lap + { + typedef Duration duration; + duration last_; + void store(duration const& d) + { + last_ = d; + } + void reset() + { + last_ = duration::zero(); + } + duration last() const { return last_; } + duration elapsed() const { return duration::zero(); } + + }; + + + } // namespace chrono +} // namespace boost + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/no_memory.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/no_memory.hpp new file mode 100644 index 0000000000..7c68b6cb0f --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/no_memory.hpp @@ -0,0 +1,36 @@ +// boost/chrono/stopwatches/collectors/no_memory.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_MEMORIES_NO_MEMORY_HPP +#define BOOST_CHRONO_STOPWATCHES_MEMORIES_NO_MEMORY_HPP + + +namespace boost +{ + namespace chrono + { + + template<typename Duration> + struct no_memory + { + typedef Duration duration; + + duration elapsed() const { return duration::zero(); } + duration last() const { return duration::zero(); } + void store(duration const& ) {} + void reset() {} + + }; + + + } // namespace chrono +} // namespace boost + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/dont_start.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/dont_start.hpp new file mode 100644 index 0000000000..e9c4df3667 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/dont_start.hpp @@ -0,0 +1,32 @@ +// boost/chrono/stopwatches/dont.hpp ------------------------------------------------------------// +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_DONT_START__HPP +#define BOOST_CHRONO_STOPWATCHES_DONT_START__HPP + +namespace boost +{ + namespace chrono + { + + /** + * Type used to don't start a basic_stopwatch at construction time. + */ + struct dont_start_t + { + }; + + /** + * Instance used to don't start a basic_stopwatch at construction time. + */ + static const dont_start_t dont_start = + { }; + + + } // namespace chrono +} // namespace boost + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp new file mode 100644 index 0000000000..dc0cf18e74 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp @@ -0,0 +1,133 @@ +// boost/chrono/stopwatches/formatters/ accumulator_set_formatter.hpp ------------------------------------------------------------// +// Copyright 2011 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/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_FORMATTERS_ACCUMULATOR_SET_HPP +#define BOOST_CHRONO_STOPWATCHES_FORMATTERS_ACCUMULATOR_SET_HPP + +#include <boost/chrono/stopwatches/formatters/base_formatter.hpp> +#include <boost/chrono/chrono_io.hpp> +#include <boost/current_function.hpp> +#include <boost/accumulators/framework/accumulator_set.hpp> +#include <boost/accumulators/statistics/count.hpp> +#include <boost/accumulators/statistics/sum.hpp> +#include <boost/accumulators/statistics/min.hpp> +#include <boost/accumulators/statistics/max.hpp> +#include <boost/accumulators/statistics/mean.hpp> +#include <boost/accumulators/accumulators.hpp> +#include <boost/format.hpp> +#include <boost/format/group.hpp> +#include <boost/cstdint.hpp> +#include <boost/assert.hpp> +#include <string> +#include <iostream> +#include <cassert> +#include <iomanip> + +#define BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT_DEFAULT "count=%1%, sum=%2%, min=%3%, max=%4%, mean=%5%\n" + +namespace boost +{ + namespace chrono + { + + template<typename Ratio = milli, typename CharT = char, + typename Traits = std::char_traits<CharT>, + class Alloc = std::allocator<CharT> > + class basic_accumulator_set_formatter: public base_formatter<CharT, Traits> , public basic_format< + CharT, Traits> + { + + public: + typedef base_formatter<CharT, Traits> base_type; + typedef basic_format<CharT, Traits> format_type; + typedef std::basic_string<CharT, Traits, Alloc> string_type; + typedef CharT char_type; + typedef std::basic_ostream<CharT, Traits> ostream_type; + + basic_accumulator_set_formatter() : + base_type(), + format_type(BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT_DEFAULT) + { + } + basic_accumulator_set_formatter(ostream_type& os) : + base_type(os), + format_type(BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT_DEFAULT) + { + } + basic_accumulator_set_formatter(const char* fmt, ostream_type& os = + std::cout) : + base_type(os), format_type(fmt) + { + } + basic_accumulator_set_formatter(string_type const& fmt, ostream_type& os = + std::cout) : + base_type(os), format_type(fmt) + { + } + + // static string_type format(const char* s) + // { + // string_type res(s); + // res += boost::chrono::detail::adaptive_string(" : "); + // res += BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT_DEFAULT; + // return res; + // } + + template<class Stopwatch> + void operator()(Stopwatch & stopwatch_ + //, system::error_code & ec = BOOST_CHRONO_THROWS + ) + { + + typedef typename Stopwatch::laps_collector::storage_type + laps_collector_acc; + laps_collector_acc const& acc = + stopwatch_.get_laps_collector().accumulator_set(); + + typedef typename Stopwatch::duration duration_t; + + duration_style_io_saver dsios(this->os_); + this->os_ + << static_cast<format_type&> (*this) + % boost::accumulators::count(acc) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), (boost::accumulators::count(acc) + == 0) ? boost::chrono::duration<double, Ratio>(duration_t::zero()) : boost::chrono::duration< + double, Ratio>(duration_t(boost::accumulators::sum(acc)))) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), (boost::accumulators::count(acc) + == 0) ? boost::chrono::duration<double, Ratio>(duration_t::zero()) : boost::chrono::duration< + double, Ratio>(duration_t((boost::accumulators::min)(acc)))) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), (boost::accumulators::count(acc) + == 0) ? boost::chrono::duration<double, Ratio>(duration_t::zero()) : boost::chrono::duration< + double, Ratio>(duration_t((boost::accumulators::max)(acc)))) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), ((boost::accumulators::count(acc) + > 0) ? boost::chrono::duration<double, Ratio>(duration_t(boost::accumulators::sum(acc) + / boost::accumulators::count(acc))) : boost::chrono::duration< + double, Ratio>(duration_t::zero()))); + + } + }; + + typedef basic_accumulator_set_formatter<milli, char> + accumulator_set_formatter; + typedef basic_accumulator_set_formatter<milli, wchar_t> + waccumulator_set_formatter; + + } // namespace chrono +} // namespace boost + +#if 0 +#define BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT(F) \ + boost::chrono::detail::adaptive_string(F " : " BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT_DEFAULT) +#ifdef __GNUC__ +#define BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FUNCTION_FORMAT \ + boost::chrono::elapsed_formatter::format(BOOST_CURRENT_FUNCTION) +#else +#define BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FUNCTION_FORMAT \ + BOOST_CHRONO_STOPWATCHES_ACCUMULATOR_SET_FORMAT(BOOST_CURRENT_FUNCTION) +#endif +#endif + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/base_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/base_formatter.hpp new file mode 100644 index 0000000000..855379ae1d --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/base_formatter.hpp @@ -0,0 +1,65 @@ +// boost/chrono/stopwatches/formatters/base_formatter.hpp ------------------------------------------------------------// +// Copyright 2011 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/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_FORMATTERS_BASE_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_FORMATTERS_BASE_FORMATTER_HPP + +#include <boost/chrono/io/duration_style.hpp> +#include <boost/chrono/duration.hpp> +#include <boost/chrono/chrono_io.hpp> +#include <boost/cstdint.hpp> +#include <iostream> +#include <iomanip> + +namespace boost +{ + namespace chrono + { + + template<typename CharT = char, typename Traits = std::char_traits<CharT> > + class base_formatter + { + base_formatter& operator=(base_formatter const& rhs) ; + + public: + typedef std::basic_ostream<CharT, Traits> ostream_type; + + base_formatter() : + precision_(3), os_(std::cout), duration_style_(duration_style::symbol) + { + } + base_formatter(ostream_type& os) : + precision_(3), os_(os), duration_style_(duration_style::symbol) + { + } + + void set_precision(std::size_t precision) + { + precision_ = precision; + if (precision_ > 9) + precision_ = 9; // sanity check + } + void set_os(ostream_type& os) + { + os_ = os; + } + void set_duration_style(duration_style style) + { + duration_style_ = style; + } + + protected: + std::size_t precision_; + ostream_type & os_; + duration_style duration_style_; + + }; + + } // namespace chrono +} // namespace boost + + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/elapsed_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/elapsed_formatter.hpp new file mode 100644 index 0000000000..7ec23c8e4e --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/elapsed_formatter.hpp @@ -0,0 +1,109 @@ +// boost/chrono/stopwatches/formatters/elapsed_formatter.hpp ------------------------------------------------------------// +// Copyright 2011 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/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_FORMATTERS_ELAPSED_HPP +#define BOOST_CHRONO_STOPWATCHES_FORMATTERS_ELAPSED_HPP + +#include <boost/chrono/stopwatches/formatters/base_formatter.hpp> +#include <boost/chrono/chrono_io.hpp> +#include <boost/current_function.hpp> +#include <boost/format.hpp> +#include <boost/format/group.hpp> +#include <boost/cstdint.hpp> +#include <boost/assert.hpp> +#include <string> +#include <iostream> +#include <cassert> +#include <iomanip> + +#define BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT_DEFAULT "%1%\n" + +namespace boost +{ + namespace chrono + { + + template<typename Ratio, typename CharT, + typename Traits = std::char_traits<CharT>, + class Alloc = std::allocator<CharT> > + class basic_elapsed_formatter: public base_formatter<CharT, Traits>, public basic_format<CharT, Traits> + { + + public: + typedef base_formatter<CharT, Traits> base_type; + typedef basic_format<CharT, Traits> format_type; + typedef std::basic_string<CharT, Traits, Alloc> string_type; + typedef CharT char_type; + typedef std::basic_ostream<CharT, Traits> ostream_type; + + basic_elapsed_formatter() : + base_type(), + format_type(BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT_DEFAULT) + { + } + basic_elapsed_formatter(ostream_type& os) : + base_type(os), + format_type(BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT_DEFAULT) + { + } + basic_elapsed_formatter(const char* fmt, ostream_type& os = std::cout) : + base_type(os), format_type(fmt) + { + } + basic_elapsed_formatter(string_type const& fmt, ostream_type& os = + std::cout) : + base_type(os), format_type(fmt) + { + } + +// static string_type format(const char* s) +// { +// string_type res(s); +// res += boost::chrono::detail::adaptive_string(" : "); +// res += BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT_DEFAULT; +// return res; +// } + + template<class Stopwatch> + void operator()(Stopwatch & stopwatch_ + //, system::error_code & ec= BOOST_CHRONO_THROWS + ) + { + typedef typename Stopwatch::duration duration_t; + duration_t d = stopwatch_.elapsed(); + //duration_t d = stopwatch_.elapsed(ec); + + if (d < duration_t::zero()) + return; + + duration_style_io_saver dsios(this->os_); + this->os_ << static_cast<format_type&>(*this) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), boost::chrono::duration< + double, Ratio>(d)) + ; + + } + }; + + typedef basic_elapsed_formatter<milli, char> elapsed_formatter; + typedef basic_elapsed_formatter<milli, wchar_t> welapsed_formatter; + + } // namespace chrono +} // namespace boost + +#if 0 +#define BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT(F) \ + boost::chrono::detail::adaptive_string(F " : " BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT_DEFAULT) +#ifdef __GNUC__ +#define BOOST_CHRONO_STOPWATCHES_ELAPSED_FUNCTION_FORMAT \ + boost::chrono::elapsed_formatter::format(BOOST_CURRENT_FUNCTION) +#else +#define BOOST_CHRONO_STOPWATCHES_ELAPSED_FUNCTION_FORMAT \ + BOOST_CHRONO_STOPWATCHES_ELAPSED_FORMAT(BOOST_CURRENT_FUNCTION) +#endif +#endif + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/times_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/times_formatter.hpp new file mode 100644 index 0000000000..4db70d08f7 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/formatters/times_formatter.hpp @@ -0,0 +1,117 @@ +// boost/chrono/stopwatches/formatters/times_formatter.hpp ------------------------------------------------------------// +// Copyright 2011 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/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_FORMATTERS_TIMES_HPP +#define BOOST_CHRONO_STOPWATCHES_FORMATTERS_TIMES_HPP + +#include <boost/chrono/stopwatches/formatters/base_formatter.hpp> +//#include <boost/chrono/detail/system.hpp> +#include <boost/current_function.hpp> +//#include <boost/chrono/stopwatches/detail/adaptive_string.hpp> +#include <boost/format.hpp> +#include <boost/format/group.hpp> +#include <boost/cstdint.hpp> +#include <boost/assert.hpp> +#include <string> +#include <iostream> +#include <cassert> +#include <iomanip> + +#define BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT_DEFAULT "real %1%, cpu %4% (%5%%%), user %2%, system %3%\n" + +namespace boost +{ + namespace chrono + { + + template<typename Ratio = milli, typename CharT = char, + typename Traits = std::char_traits<CharT>, + class Alloc = std::allocator<CharT> > + class basic_times_formatter: public base_formatter<CharT, Traits>, public basic_format<CharT, Traits> + { + + public: + typedef base_formatter<CharT, Traits> base_type; + typedef basic_format<CharT, Traits> format_type; + typedef std::basic_string<CharT, Traits, Alloc> string_type; + typedef CharT char_type; + typedef std::basic_ostream<CharT, Traits> ostream_type; + + basic_times_formatter() : + base_type(), + format_type(BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT_DEFAULT) + { + } + basic_times_formatter(ostream_type& os) : + base_type(os), + format_type(BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT_DEFAULT) + { + } + basic_times_formatter(const char* fmt, ostream_type& os = std::cout) : + base_type(os), format_type(fmt) + { + } + basic_times_formatter(string_type const& fmt, ostream_type& os = + std::cout) : + base_type(os), format_type(fmt) + { + } + +// static string_type format(const char* s) +// { +// string_type res(s); +// res += boost::chrono::detail::adaptive_string(" : "); +// res += BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT_DEFAULT; +// return res; +// } + + template<class Stopwatch> + void operator()(Stopwatch & stopwatch_ + //, system::error_code & ec= BOOST_CHRONO_THROWS + ) + { + typedef typename Stopwatch::duration::rep times_type; + //times_type times = stopwatch_.elapsed(ec).count(); + times_type times = stopwatch_.elapsed().count(); + + if (times.real < 0) + return; + double p; + if (times.real > 0) + p=double(times.user+times.system)*100/times.real; + else + p=0; + + duration_style_io_saver dsios(this->os_); + this->os_ << static_cast<format_type&>(*this) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), boost::chrono::duration<double, Ratio>(nanoseconds(times.real))) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), boost::chrono::duration<double, Ratio>(nanoseconds(times.user))) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), boost::chrono::duration<double, Ratio>(nanoseconds(times.system))) + % io::group(std::fixed, std::setprecision(this->precision_), duration_fmt(this->duration_style_), boost::chrono::duration<double, Ratio>(nanoseconds(times.user+times.system))) + % io::group(std::fixed, std::setprecision(2), p) + ; + } + }; + + typedef basic_times_formatter<milli, char> times_formatter; + typedef basic_times_formatter<milli, wchar_t> wtimes_formatter; + + } // namespace chrono +} // namespace boost + +#if 0 +#define BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT(F) \ + boost::chrono::detail::adaptive_string(F " : " BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT_DEFAULT) +#ifdef __GNUC__ +#define BOOST_CHRONO_STOPWATCHES_TIMES_FUNCTION_FORMAT \ + boost::chrono::times_formatter::format(BOOST_CURRENT_FUNCTION) +#else +#define BOOST_CHRONO_STOPWATCHES_TIMES_FUNCTION_FORMAT \ + BOOST_CHRONO_STOPWATCHES_TIMES_FORMAT(BOOST_CURRENT_FUNCTION) +#endif +#endif + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/laps_stopwatch.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/laps_stopwatch.hpp new file mode 100644 index 0000000000..981644193a --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/laps_stopwatch.hpp @@ -0,0 +1,442 @@ +// boost/chrono/stopwatches/laps_stopwatch.hpp -----------------------------// + +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_LAPS_STOPWATCH_HPP +#define BOOST_CHRONO_STOPWATCHES_LAPS_STOPWATCH_HPP + + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/stopwatches/stopwatch_scoped.hpp> +#include <boost/chrono/stopwatches/collectors/no_memory.hpp> // default laps_collector +#include <boost/chrono/stopwatches/dont_start.hpp> +#include <boost/chrono/system_clocks.hpp> // default_clock +#include <boost/system/error_code.hpp> +#include <utility> + +namespace boost +{ + namespace chrono + { + + + /** + * A laps_stopwatch is a model of @c Stopwatch taking as template parameters the @c Clock and the @c LapsCollector. + * + * The main difference respect to a @c simple_stopwatch is that the user can stop it. + * Each sequence of start-stop results in a new elapsed duration sample that is provided to the LapsCollector. + * + * It is up to the LapsCollector to make whatever wants with each sample. + * A LapCollector must define a store(duration const&) and a clear() functions. + * + * The library provides LapsCollectors that forget the sample, store the + * last one, cummulates the samples in an accumulator set or store them in a container. + * For simplicity the default LapCollector is the one that forget the samples. + * + * Even if it is preferable to use process or thread wide clocks, + * the default of the Clock parameter is high_resolution_clock, + * as it is the single one ensured on all platforms. + */ + template<typename Clock=high_resolution_clock, typename LapsCollector=no_memory<typename Clock::duration> > + class laps_stopwatch + { + public: + typedef LapsCollector laps_collector; + typedef Clock clock; + typedef typename Clock::duration duration; + typedef typename Clock::time_point time_point; + typedef typename Clock::rep rep; + typedef typename Clock::period period; + BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady; + + /** + * Default constructor. + * + * Effects: Starts the stopwatch. + * Post-conditions: is_running(). + */ + explicit laps_stopwatch() + : + start_(duration::zero()), + running_(false), + laps_collector_() + { + start(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Default constructor. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Starts the stopwatch. + * Post-conditions: is_running() if no error occur. + */ + explicit laps_stopwatch( + system::error_code & ec + ) : + start_(duration::zero()), + running_(false), + laps_collector_() + { + start(ec); + } +#endif + /** + * Not starting constructor. + * + * Effects: Don't starts the stopwatch. + * Post-conditions: ! is_running() if no error occur. + */ + explicit laps_stopwatch( + const dont_start_t& + ) : + start_(duration::zero()), + running_(false), + laps_collector_() + { + } + + /** + * Starting constructor from a LapsCollector instance. + * + * Effects: Copies the LapsCollector. Starts the stopwatch. + * Post-conditions: is_running() if no error occur. + * + * Remark: The LapsCollector is copied and owned by the stopwatch. + */ + explicit laps_stopwatch( + laps_collector const& acc + ) : + start_(duration::zero()), + running_(false), + laps_collector_(acc) + { + start(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Starting constructor from a LapsCollector instance. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Copies the LapsCollector. Starts the stopwatch. + * Post-conditions: is_running() if no error occur. + * + * Remark: The LapsCollector is copied and owned by the stopwatch. + */ + explicit laps_stopwatch( + laps_collector const& acc, + system::error_code & ec + ) : + start_(duration::zero()), + running_(false), + laps_collector_(acc) + { + start(ec); + } +#endif + + /** + * Not starting constructor from a LapsCollector instance. + * + * Effects: Copies the LapsCollector. Don't starts the stopwatch. + * Post-conditions: ! is_running() if no error occur. + * + * Remark: The LapsCollector is copied and owned by the stopwatch. + */ + laps_stopwatch( + laps_collector const& acc, + const dont_start_t& + ) : + start_(duration::zero()), + running_(false), + laps_collector_(acc) + { + } + + /** + * Destructor. + * + * Effects: Do nothing. + */ + ~laps_stopwatch() + { + } + + /** + * Restart the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: As if stop(); start() were called, but ensuring that the start time is the same as the stop time. + * + * Post-conditions: is_running() if no error occur. + */ + void restart() + { + time_point tmp = clock::now(); + + if (is_running()) + { + laps_collector_.store(tmp - start_); + } + else + { + running_ = true; + } + start_ = tmp; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Restart the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: As if stop(); start() were called, but ensuring that the start time is the same as the stop time. + * + * Post-conditions: is_running() if no error occur. + */ + void restart( + system::error_code & ec + ) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + if (is_running()) + { + laps_collector_.store(tmp - start_); + } + else + { + running_ = true; + } + start_ = tmp; + } +#endif + + /** + * Start the stopwatch. + * + * Effects: Memorize the current time. + * + * Post-conditions: is_running(). + */ + void start() + { + start_ = clock::now(); + running_ = true; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Start the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Memorize the current time. + * + * Post-conditions: is_running() if no error occur. + */ + void start( + system::error_code & ec + ) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + start_ = tmp; + running_ = true; + } +#endif + + /** + * Start the stopwatch. + * + * Effects: Gives the elapsed time since start time to the LapCollector. + * + * Throws: Any exception that the LapCollector can throw when . + * + * Post-conditions: !is_running() if no error occur. + */ + void stop() + { + if (is_running()) + { + laps_collector_.store(clock::now() - start_); + start_ = time_point(duration::zero()); + running_ = false; + } + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Start the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Gives the elapsed time since start time to the LapCollector if no internal error occurs. + * + * Throws: Any exception that the LapCollector can Throw. + * + * Post-conditions: !is_running() if no error occur. + */ + void stop( + system::error_code & ec + ) + { + if (is_running()) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + laps_collector_.store(tmp - start_); + start_ = time_point(duration::zero()); + running_ = false; + } + } +#endif + + /** + * States if the Stopwatch is running. + */ + bool is_running() const { + return running_; + } + + /** + * Elapsed time getter for the current lap. + * + * Returns: the elapsed time since the last start if no internal error occur. + * + */ + duration elapsed_current_lap() const + { + if (is_running()) + { + return clock::now() - start_; + } + else + { + return duration::zero(); + } + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Elapsed time getter for the current lap. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * + * Returns: the elapsed time since the start if no internal error occur. + * + */ + duration elapsed_current_lap( + system::error_code & ec + ) const + { + if (is_running()) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return duration::zero(); + + return tmp - start_; + } else + { + return duration::zero(); + } + } +#endif + + /** + * Elapsed time getter. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * + * Returns: the elapsed time since the start if no internal error occur. + * + */ + duration elapsed() const + { + return laps_collector_.elapsed()+elapsed_current_lap(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Elapsed time getter. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * + * Returns: the elapsed time since the start if no internal error occur. + * + */ + duration elapsed( + system::error_code & ec + ) const + { + duration tmp = elapsed_current_lap(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return duration::zero(); + return laps_collector_.elapsed() + tmp; + } +#endif + /** + * Elapsed time for the last lap. + * + * Returns: the elapsed time of the last lap. + * + */ + + duration last() const + { + return laps_collector_.last(); + } + /** + * Resets the stopwatch. + * + * Effects: Resets the LapCollector. + * + * Post-conditions: !is_running() if no error occur. + * + */ + void reset() + { + + laps_collector_.reset(); + running_ = false; + start_ = time_point(duration::zero()); + } + + /** + * LapsCollector getter. + * + * Returns: the LapCollector instance. + * + */ + laps_collector const& get_laps_collector() BOOST_NOEXCEPT + { + return laps_collector_; + } + + /** + * Useful typedef for scoped run + */ + typedef stopwatch_runner<laps_stopwatch<Clock, LapsCollector> > + scoped_run; + /** + * Useful typedef for scoped stop + */ + typedef stopwatch_stopper<laps_stopwatch<Clock, LapsCollector> > + scoped_stop; + + private: + time_point start_; + bool running_; + laps_collector laps_collector_; + }; + + } // namespace chrono +} // namespace boost + +#endif // header diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/clock_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/clock_default_formatter.hpp new file mode 100644 index 0000000000..d85039ab62 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/clock_default_formatter.hpp @@ -0,0 +1,31 @@ +// boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_CLOCK_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_CLOCK_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/stopwatches/formatters/elapsed_formatter.hpp> + +namespace boost +{ + namespace chrono + { + + template<class CharT, class Clock> + struct basic_clock_default_formatter + { + typedef basic_elapsed_formatter<milli, CharT> type; + }; + + } // namespace chrono +} // namespace boost + + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_accumulator_set_stopwatch_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_accumulator_set_stopwatch_default_formatter.hpp new file mode 100644 index 0000000000..239833fcfc --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_accumulator_set_stopwatch_default_formatter.hpp @@ -0,0 +1,34 @@ +// boost/chrono/stopwatches/reporters/laps_accumulator_set_stopwatch_default_formatter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPWATCH_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPWATCH_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp> +#include <boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp> +#include <boost/chrono/stopwatches/stopwatch.hpp> +#include <boost/chrono/thread_clock.hpp> + +namespace boost +{ + namespace chrono + { + + template <typename CharT, typename Clock, typename Features, typename Weight> + struct basic_stopwatch_reporter_default_formatter<CharT, stopwatch<Clock,laps_accumulator_set<typename Clock::duration,Features, Weight> > > + { + typedef basic_accumulator_set_formatter<milli,CharT> type; + }; + + } // namespace chrono +} // namespace boost + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_stopclock.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_stopclock.hpp new file mode 100644 index 0000000000..4debbc5518 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_stopclock.hpp @@ -0,0 +1,176 @@ +// boost/chrono/stopwatches/reporters/stopclock.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. +#error + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPCLOCK_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPCLOCK_HPP + +#include <boost/chrono/config.hpp> + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __GNUC__ +#pragma GCC system_header +#elif defined __SUNPRO_CC +#pragma disable_warn +#elif defined _MSC_VER +#pragma warning(push, 1) +#endif +#endif + +#include <boost/chrono/stopwatches/reporters/laps_stopwatch_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp> +#include <boost/chrono/stopwatches/stopwatch_scoped.hpp> +#include <boost/chrono/stopwatches/stopwatch.hpp> +#include <boost/chrono/stopwatches/dont_start.hpp> +#include <boost/chrono/chrono.hpp> +#include <boost/system/error_code.hpp> +#include <boost/cstdint.hpp> +#include <cassert> + +namespace boost +{ + namespace chrono + { + + template<class CharT, typename Clock, typename LapsCollector, class Formatter> + class basic_stopclock: public basic_stopwatch_reporter<CharT, stopwatch<Clock, LapsCollector>, Formatter> + { + public: + typedef basic_stopwatch_reporter<CharT, stopwatch<Clock, LapsCollector>, Formatter> base_type; + typedef Clock clock; + typedef stopwatch<Clock, LapsCollector> stopwatch; + typedef Formatter formatter_type; + + basic_stopclock() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit basic_stopclock(system::error_code & ec) : + base_type(ec) + { + } +#endif + explicit basic_stopclock( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag) + { + } + + explicit basic_stopclock(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit basic_stopclock(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit basic_stopclock(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + typedef stopwatch_runner<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_run; + typedef stopwatch_stopper<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_stop; + typedef stopwatch_suspender<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_suspend; + typedef stopwatch_resumer<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_resume; + + protected: + + basic_stopclock(const basic_stopclock&); // = delete; + basic_stopclock& operator=(const basic_stopclock&); // = delete; + }; + + + template<typename Clock=high_resolution_clock, typename LapsCollector=no_memory<typename Clock::duration>, + class Formatter = typename basic_stopwatch_reporter_default_formatter<char, stopwatch<Clock, LapsCollector> >::type> + class stopclock; + + template<class Stopwatch, class Formatter> + struct basic_stopwatch_reporter_default_formatter<char, stopclock<Stopwatch, + Formatter> > + { + typedef Formatter type; + }; + + template<typename Clock, typename LapsCollector, class Formatter> + class stopclock: public basic_stopclock<char, Clock, LapsCollector, Formatter> + { + typedef basic_stopclock<char, Clock, LapsCollector, Formatter> base_type; + public: + typedef Clock clock; + typedef typename base_type::stopwatch stopwatch; + typedef Formatter formatter_type; + + stopclock() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit stopclock(system::error_code & ec) : + base_type(ec) + { + } +#endif + explicit stopclock( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag) + { + } + + explicit stopclock(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit stopclock(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit stopclock(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + typedef stopwatch_runner<stopclock<Clock, LapsCollector, Formatter> > + scoped_run; + typedef stopwatch_stopper<stopclock<Clock, LapsCollector, Formatter> > + scoped_stop; + typedef stopwatch_suspender<stopclock<Clock, LapsCollector, Formatter> > + scoped_suspend; + typedef stopwatch_resumer<stopclock<Clock, LapsCollector, Formatter> > + scoped_resume; + + protected: + + stopclock(const stopclock&); // = delete; + stopclock& operator=(const stopclock&); // = delete; + }; + + + + } // namespace chrono +} // namespace boost + + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __SUNPRO_CC +#pragma enable_warn +#elif defined _MSC_VER +#pragma warning(pop) +#endif +#endif + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_stopwatch_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_stopwatch_default_formatter.hpp new file mode 100644 index 0000000000..e157eb39d2 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/laps_stopwatch_default_formatter.hpp @@ -0,0 +1,37 @@ +// boost/chrono/stopwatches/reporters/laps_stopwatch_default_formatter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPWATCH_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPWATCH_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/formatters/accumulator_set_formatter.hpp> +#include <boost/chrono/stopwatches/collectors/laps_accumulator_set.hpp> +#include <boost/chrono/stopwatches/laps_stopwatch.hpp> +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP +#include <boost/chrono/thread_clock.hpp> +#endif + +namespace boost +{ + namespace chrono + { + + template <typename CharT, typename Clock, typename Features, typename Weight> + struct basic_stopwatch_reporter_default_formatter<CharT, laps_stopwatch<Clock,laps_accumulator_set<typename Clock::duration,Features, Weight> > > + { + typedef basic_accumulator_set_formatter<milli,CharT> type; + }; + + } // namespace chrono +} // namespace boost + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/process_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/process_default_formatter.hpp new file mode 100644 index 0000000000..4b3c1c58e9 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/process_default_formatter.hpp @@ -0,0 +1,42 @@ +// boost/chrono/stopwatches/reporters/process_default_formatter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_PROCESS_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_PROCESS_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/clock_default_formatter.hpp> +#include <boost/chrono/stopwatches/formatters/elapsed_formatter.hpp> +#include <boost/chrono/stopwatches/formatters/times_formatter.hpp> +#include <boost/chrono/process_cpu_clocks.hpp> + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + +namespace boost +{ + namespace chrono + { +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + + template <typename CharT> + struct basic_clock_default_formatter<CharT, process_cpu_clock> + { + typedef basic_times_formatter<milli, CharT> type; + }; + +#endif + } // namespace chrono +} // namespace boost + + +#endif + +#endif + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopclock.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopclock.hpp new file mode 100644 index 0000000000..937cabdd45 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopclock.hpp @@ -0,0 +1,175 @@ +// boost/chrono/stopwatches/reporters/stopclock.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPCLOCK_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_LAPS_STOPCLOCK_HPP + +#include <boost/chrono/config.hpp> + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __GNUC__ +#pragma GCC system_header +#elif defined __SUNPRO_CC +#pragma disable_warn +#elif defined _MSC_VER +#pragma warning(push, 1) +#endif +#endif + +#include <boost/chrono/stopwatches/reporters/laps_accumulator_set_stopwatch_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp> +#include <boost/chrono/stopwatches/stopwatch_scoped.hpp> +#include <boost/chrono/stopwatches/stopwatch.hpp> +#include <boost/chrono/stopwatches/dont_start.hpp> +#include <boost/chrono/chrono.hpp> +#include <boost/chrono/detail/system.hpp> +#include <boost/cstdint.hpp> +#include <cassert> + +namespace boost +{ + namespace chrono + { + + template<class CharT, typename Clock, typename LapsCollector, class Formatter> + class basic_stopclock: public basic_stopwatch_reporter<CharT, stopwatch<Clock, LapsCollector>, Formatter> + { + public: + typedef basic_stopwatch_reporter<CharT, stopwatch<Clock, LapsCollector>, Formatter> base_type; + typedef Clock clock; + typedef stopwatch<Clock, LapsCollector> stopwatch_type; + typedef Formatter formatter_type; + + basic_stopclock() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit basic_stopclock(system::error_code & ec) : + base_type(ec) + { + } +#endif + explicit basic_stopclock( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag) + { + } + + explicit basic_stopclock(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit basic_stopclock(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit basic_stopclock(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + typedef stopwatch_runner<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_run; + typedef stopwatch_stopper<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_stop; + typedef stopwatch_suspender<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_suspend; + typedef stopwatch_resumer<basic_stopclock<CharT,Clock, LapsCollector, Formatter> > + scoped_resume; + + protected: + + basic_stopclock(const basic_stopclock&); // = delete; + basic_stopclock& operator=(const basic_stopclock&); // = delete; + }; + + + template<typename Clock=high_resolution_clock, typename LapsCollector=no_memory<typename Clock::duration>, + class Formatter = typename basic_stopwatch_reporter_default_formatter<char, stopwatch<Clock, LapsCollector> >::type> + class stopclock; + + template<class Stopwatch, class Formatter> + struct basic_stopwatch_reporter_default_formatter<char, stopclock<Stopwatch, + Formatter> > + { + typedef Formatter type; + }; + + template<typename Clock, typename LapsCollector, class Formatter> + class stopclock: public basic_stopclock<char, Clock, LapsCollector, Formatter> + { + typedef basic_stopclock<char, Clock, LapsCollector, Formatter> base_type; + public: + typedef Clock clock; + typedef typename base_type::stopwatch_type stopwatch_type; + typedef Formatter formatter_type; + + stopclock() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit stopclock(system::error_code & ec) : + base_type(ec) + { + } +#endif + explicit stopclock( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag) + { + } + + explicit stopclock(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit stopclock(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit stopclock(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + typedef stopwatch_runner<stopclock<Clock, LapsCollector, Formatter> > + scoped_run; + typedef stopwatch_stopper<stopclock<Clock, LapsCollector, Formatter> > + scoped_stop; + typedef stopwatch_suspender<stopclock<Clock, LapsCollector, Formatter> > + scoped_suspend; + typedef stopwatch_resumer<stopclock<Clock, LapsCollector, Formatter> > + scoped_resume; + + protected: + + stopclock(const stopclock&); // = delete; + stopclock& operator=(const stopclock&); // = delete; + }; + + + + } // namespace chrono +} // namespace boost + + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __SUNPRO_CC +#pragma enable_warn +#elif defined _MSC_VER +#pragma warning(pop) +#endif +#endif + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp new file mode 100644 index 0000000000..8d379cd9cf --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp @@ -0,0 +1,259 @@ +// boost/chrono/stopwatches/stopwatch_reporter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_STOPWATCH_REPORTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_STOPWATCH_REPORTER_HPP + +#include <boost/chrono/config.hpp> + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __GNUC__ +#pragma GCC system_header +#elif defined __SUNPRO_CC +#pragma disable_warn +#elif defined _MSC_VER +#pragma warning(push, 1) +#endif +#endif + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/stopwatch_scoped.hpp> +#include <boost/chrono/stopwatches/dont_start.hpp> +#include <boost/chrono/chrono.hpp> +#include <boost/chrono/detail/system.hpp> +#include <boost/cstdint.hpp> +#include <cassert> + +namespace boost +{ + namespace chrono + { + + template<class CharT, class Stopwatch, class Formatter=basic_stopwatch_reporter_default_formatter<CharT, Stopwatch> > + class basic_stopwatch_reporter: public Stopwatch + { + public: + typedef Stopwatch base_type; + typedef typename Stopwatch::clock clock; + typedef Stopwatch stopwatch_type; + typedef Formatter formatter_type; + + basic_stopwatch_reporter() BOOST_NOEXCEPT : + formatter_(), reported_(false) + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit basic_stopwatch_reporter(system::error_code & ec) : + base_type(ec), formatter_(), reported_(false) + { + } +#endif + + explicit basic_stopwatch_reporter( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag), + formatter_(), reported_(false) + { + } + + explicit basic_stopwatch_reporter(const typename Formatter::char_type* fmt) : + formatter_(fmt), reported_(false) + { + } + explicit basic_stopwatch_reporter(typename Formatter::string_type const& fmt) : + formatter_(fmt), reported_(false) + { + } + explicit basic_stopwatch_reporter(formatter_type fmt) : + formatter_(fmt), reported_(false) + { + } + + ~basic_stopwatch_reporter() BOOST_NOEXCEPT + { + if (!reported()) + { + this->report(); + } + } + + inline void report() BOOST_NOEXCEPT + { + formatter_(*this); + reported_ = true; + } +// inline void report(system::error_code & ec) +// { +// formatter_(*this, ec); +// reported_ = true; +// } + + bool reported() const + { + return reported_; + } + + formatter_type& format() + { + return formatter_; + } + + protected: + formatter_type formatter_; + bool reported_; + + basic_stopwatch_reporter(const basic_stopwatch_reporter&); // = delete; + basic_stopwatch_reporter& operator=(const basic_stopwatch_reporter&); // = delete; + }; + + + template<class Stopwatch, + class Formatter = typename basic_stopwatch_reporter_default_formatter<char, Stopwatch>::type> + class stopwatch_reporter; + + template<class Stopwatch, class Formatter> + struct basic_stopwatch_reporter_default_formatter<char, stopwatch_reporter<Stopwatch, Formatter> > + { + typedef Formatter type; + }; + + template<class Stopwatch, class Formatter> + class stopwatch_reporter: public basic_stopwatch_reporter<char, Stopwatch, + Formatter> + { + typedef basic_stopwatch_reporter<char, Stopwatch, Formatter> base_type; + public: + typedef typename Stopwatch::clock clock; + typedef Stopwatch stopwatch_type; + typedef Formatter formatter_type; + + stopwatch_reporter() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit stopwatch_reporter(system::error_code & ec) : + base_type(ec) + { + } +#endif + explicit stopwatch_reporter( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag) + { + } + + explicit stopwatch_reporter(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit stopwatch_reporter(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit stopwatch_reporter(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + typedef stopwatch_runner<stopwatch_reporter<Stopwatch, Formatter> > + scoped_run; + typedef stopwatch_stopper<stopwatch_reporter<Stopwatch, Formatter> > + scoped_stop; + typedef stopwatch_suspender<stopwatch_reporter<Stopwatch, Formatter> > + scoped_suspend; + typedef stopwatch_resumer<stopwatch_reporter<Stopwatch, Formatter> > + scoped_resume; + + protected: + + stopwatch_reporter(const stopwatch_reporter&); // = delete; + stopwatch_reporter& operator=(const stopwatch_reporter&); // = delete; + }; + + template<class Stopwatch, + class Formatter = typename basic_stopwatch_reporter_default_formatter<wchar_t, + Stopwatch>::type> + class wstopwatch_reporter; + + template<class Stopwatch, class Formatter> + struct basic_stopwatch_reporter_default_formatter<wchar_t, wstopwatch_reporter<Stopwatch, Formatter> > + { + typedef Formatter type; + }; + + template<class Stopwatch, class Formatter> + class wstopwatch_reporter: public basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter> + { + typedef basic_stopwatch_reporter<wchar_t, Stopwatch, Formatter> base_type; + public: + typedef typename Stopwatch::clock clock; + typedef Stopwatch stopwatch_type; + typedef Formatter formatter_type; + + wstopwatch_reporter() : + base_type() + { + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit wstopwatch_reporter(system::error_code & ec) : + base_type(ec) + { + } +#endif + explicit wstopwatch_reporter( + const dont_start_t& tag + ) BOOST_NOEXCEPT : + base_type(tag) + { + } + + explicit wstopwatch_reporter(formatter_type const& fmt) : + base_type(fmt) + { + } + explicit wstopwatch_reporter(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit wstopwatch_reporter(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + typedef stopwatch_runner<wstopwatch_reporter<Stopwatch, Formatter> > + scoped_run; + typedef stopwatch_stopper<wstopwatch_reporter<Stopwatch, Formatter> > + scoped_stop; + typedef stopwatch_suspender<wstopwatch_reporter<Stopwatch, Formatter> > + scoped_suspend; + typedef stopwatch_resumer<wstopwatch_reporter<Stopwatch, Formatter> > + scoped_resume; + + protected: + + wstopwatch_reporter(const wstopwatch_reporter&); // = delete; + wstopwatch_reporter& operator=(const wstopwatch_reporter&); // = delete; + }; + + } // namespace chrono +} // namespace boost + + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __SUNPRO_CC +#pragma enable_warn +#elif defined _MSC_VER +#pragma warning(pop) +#endif +#endif + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp new file mode 100644 index 0000000000..bd81214eb2 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp @@ -0,0 +1,31 @@ +// boost/chrono/stopwatches/stopwatch_reporter_default_formatter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/stopwatches/reporters/clock_default_formatter.hpp> + +namespace boost +{ + namespace chrono + { + + template <class CharT, class Stopwatch> + struct basic_stopwatch_reporter_default_formatter + : basic_clock_default_formatter<CharT, typename Stopwatch::clock> + { + }; + + } // namespace chrono +} // namespace boost + + + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/strict_stopclock.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/strict_stopclock.hpp new file mode 100644 index 0000000000..2252c8049a --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/strict_stopclock.hpp @@ -0,0 +1,143 @@ +// boost/chrono/stopwatches/reporters/strict_stopclock.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_STRICT_STOPCLOCK_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_STRICT_STOPCLOCK_HPP + +#include <boost/chrono/config.hpp> + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __GNUC__ +#pragma GCC system_header +#elif defined __SUNPRO_CC +#pragma disable_warn +#elif defined _MSC_VER +#pragma warning(push, 1) +#endif +#endif + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter.hpp> +#include <boost/chrono/stopwatches/strict_stopwatch.hpp> +#include <boost/chrono/chrono.hpp> +#include <boost/chrono/detail/system.hpp> +#include <boost/cstdint.hpp> +#include <cassert> + +namespace boost +{ + namespace chrono + { + + template<class CharT, typename Clock, class Formatter> + class basic_strict_stopclock: public basic_stopwatch_reporter<CharT, strict_stopwatch<Clock>, Formatter> + { + public: + typedef basic_stopwatch_reporter<CharT, strict_stopwatch<Clock>, Formatter> base_type; + typedef Clock clock; + typedef strict_stopwatch<Clock> stopwatch; + typedef Formatter formatter_type; + + basic_strict_stopclock() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit basic_strict_stopclock(system::error_code & ec) : + base_type(ec) + { + } +#endif + + explicit basic_strict_stopclock(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit basic_strict_stopclock(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit basic_strict_stopclock(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + + protected: + + basic_strict_stopclock(const basic_strict_stopclock&); // = delete; + basic_strict_stopclock& operator=(const basic_strict_stopclock&); // = delete; + }; + + + template<typename Clock=high_resolution_clock, + class Formatter = typename basic_stopwatch_reporter_default_formatter<char, strict_stopwatch<Clock> >::type> + class strict_stopclock; + + template<class Stopwatch, class Formatter> + struct basic_stopwatch_reporter_default_formatter<char, strict_stopclock<Stopwatch, Formatter> > + { + typedef Formatter type; + }; + + template<typename Clock, class Formatter> + class strict_stopclock: public basic_strict_stopclock<char, Clock, Formatter> + { + typedef basic_strict_stopclock<char, Clock, Formatter> base_type; + public: + typedef Clock clock; + typedef typename base_type::stopwatch stopwatch; + typedef Formatter formatter_type; + + strict_stopclock() + { + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit strict_stopclock(system::error_code & ec) : + base_type(ec) + { + } +#endif + + explicit strict_stopclock(formatter_type const& fmt) : + base_type(fmt) + { + } + + explicit strict_stopclock(const typename Formatter::char_type* fmt) : + base_type(fmt) + { + } + explicit strict_stopclock(typename Formatter::string_type const& fmt) : + base_type(fmt) + { + } + + protected: + + strict_stopclock(const strict_stopclock&); // = delete; + strict_stopclock& operator=(const strict_stopclock&); // = delete; + }; + + + + } // namespace chrono +} // namespace boost + + +#if !defined(BOOST_ENABLE_WARNINGS) && !defined(BOOST_CHRONO_ENABLE_WARNINGS) +#if defined __SUNPRO_CC +#pragma enable_warn +#elif defined _MSC_VER +#pragma warning(pop) +#endif +#endif + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/system_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/system_default_formatter.hpp new file mode 100644 index 0000000000..ed2a384412 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/system_default_formatter.hpp @@ -0,0 +1,19 @@ +// boost/chrono/stopwatches/reporters/system_default_formatter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_SYSTEM_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_SYSTEM_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/clock_default_formatter.hpp> +#include <boost/chrono/stopwatches/formatters/elapsed_formatter.hpp> +#include <boost/chrono/system_clocks.hpp> + + + +#endif + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/thread_default_formatter.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/thread_default_formatter.hpp new file mode 100644 index 0000000000..40b0eb7d14 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/reporters/thread_default_formatter.hpp @@ -0,0 +1,26 @@ +// boost/chrono/stopwatches/reporters/thread_default_formatter.hpp +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or +// copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_REPORTERS_THREAD_DEFAULT_FORMATTER_HPP +#define BOOST_CHRONO_STOPWATCHES_REPORTERS_THREAD_DEFAULT_FORMATTER_HPP + +#include <boost/chrono/config.hpp> + +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + +#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp> +#include <boost/chrono/stopwatches/reporters/clock_default_formatter.hpp> +#include <boost/chrono/stopwatches/formatters/elapsed_formatter.hpp> +#include <boost/chrono/thread_clock.hpp> + + + +#endif + +#endif + + diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/simple_stopwatch.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/simple_stopwatch.hpp new file mode 100644 index 0000000000..f36acbb714 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/simple_stopwatch.hpp @@ -0,0 +1,110 @@ +// boost/chrono/stopwatches/simple_stopwatch.hpp ------------------------------------------------------------// +// Copyright 2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_SIMPLE_STOPWATCH__HPP +#define BOOST_CHRONO_STOPWATCHES_SIMPLE_STOPWATCH__HPP + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/chrono.hpp> +#include <boost/system/error_code.hpp> +#include <boost/chrono/thread_clock.hpp> +#include <boost/chrono/process_cpu_clocks.hpp> +#include <utility> + +namespace boost +{ + namespace chrono + { + + /** + * This class provides the simpler stopwatch which is just able to give the elapsed time since its construction. + */ + template<typename Clock=high_resolution_clock> + class simple_stopwatch + { + public: + typedef Clock clock; + typedef typename Clock::duration duration; + typedef typename Clock::time_point time_point; + typedef typename Clock::rep rep; + typedef typename Clock::period period; + BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady; + + + simple_stopwatch() : + start_(clock::now()) + { + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit simple_stopwatch(system::error_code & ec) : + start_(duration::zero()) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec)) + { + if (ec) + { + return; + } + } + start_ = tmp; + } +#endif + + ~simple_stopwatch() BOOST_NOEXCEPT + { + } + + duration elapsed() + { + return clock::now() - start_; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + duration elapsed(system::error_code & ec) BOOST_NOEXCEPT + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec)) + { + if (ec) + return duration::zero(); + } + return tmp - start_; + } +#endif + + private: + time_point start_; + simple_stopwatch(const simple_stopwatch&); // = delete; + simple_stopwatch& operator=(const simple_stopwatch&); // = delete; + }; + + typedef simple_stopwatch<system_clock> system_simple_stopwatch; +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + typedef simple_stopwatch<steady_clock> steady_simple_stopwatch; +#endif + typedef simple_stopwatch<high_resolution_clock> high_resolution_simple_stopwatch; + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + typedef simple_stopwatch<process_real_cpu_clock> process_real_cpu_simple_stopwatch; +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + typedef simple_stopwatch<process_user_cpu_clock> process_user_cpu_simple_stopwatch; + typedef simple_stopwatch<process_system_cpu_clock> process_system_cpu_simple_stopwatch; + typedef simple_stopwatch<process_cpu_clock> process_cpu_simple_stopwatch; +#endif +#endif + +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + typedef simple_stopwatch<thread_clock> thread_simple_stopwatch; +#endif + + + } // namespace chrono +} // namespace boost + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/stopwatch.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/stopwatch.hpp new file mode 100644 index 0000000000..afa00806bf --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/stopwatch.hpp @@ -0,0 +1,444 @@ +// boost/chrono/stopwatches/stopwatch.hpp -----------------------------// + +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_STOPWATCH_HPP +#define BOOST_CHRONO_STOPWATCHES_STOPWATCH_HPP + + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/stopwatches/stopwatch_scoped.hpp> +#include <boost/chrono/stopwatches/collectors/no_memory.hpp> // default laps_collector +#include <boost/chrono/stopwatches/dont_start.hpp> +#include <boost/chrono/system_clocks.hpp> // default_clock +#include <boost/chrono/detail/system.hpp> +#include <utility> + +namespace boost +{ + namespace chrono + { + + + /** + * A stopwatch is a model of @c Stopwatch taking as parameters the @c Clock and the @c LapsCollector. + * + * The main difference respect to a @c simple_stopwatch is that the user can stop it. + * Each sequence of start-stop results in a new elapsed duration sample that is provided to the LapsCollector. + * + * It is up to the LapsCollector to do whatever it wants with each sample. + * A LapCollector must define a store(duration const&) and a clear() functions. + * + * The library provides LapsCollectors that forget the sample, store the + * last one, cummulates the samples in an accumulator set or store them in a container. + * For simplicity the default LapCollector is the one that forget the samples. + * + * Even if it is preferable to use process or thread wide clocks, + * the default of the Clock parameter is high_resolution_clock, + * as it is the single one ensured on all platforms. + */ + template<typename Clock=high_resolution_clock, typename LapsCollector=no_memory<typename Clock::duration> > + class stopwatch + { + public: + typedef LapsCollector laps_collector; + typedef Clock clock; + typedef typename Clock::duration duration; + typedef typename Clock::time_point time_point; + typedef typename Clock::rep rep; + typedef typename Clock::period period; + BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady; + + /** + * Default constructor. + * + * Effects: Starts the stopwatch. + * Post-conditions: is_running(). + */ + stopwatch() + : + start_(duration::zero()), + running_(false), + laps_collector_() + { + start(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Default constructor. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Starts the stopwatch. + * Post-conditions: is_running() if no error occur. + */ + explicit stopwatch( + system::error_code & ec + ) : + start_(duration::zero()), + running_(false), + laps_collector_() + { + start(ec); + } +#endif + /** + * Not starting constructor. + * + * Effects: Don't starts the stopwatch. + * Post-conditions: ! is_running() if no error occur. + */ + explicit stopwatch( + const dont_start_t& + ) : + start_(duration::zero()), + running_(false), + laps_collector_() + { + } + + /** + * Starting constructor from a LapsCollector instance. + * + * Effects: Copies the LapsCollector. Starts the stopwatch. + * Post-conditions: is_running() if no error occur. + * + * Remark: The LapsCollector is copied and owned by the stopwatch. + */ + explicit stopwatch( + laps_collector const& acc + ) : + start_(duration::zero()), + running_(false), + laps_collector_(acc) + { + start(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Starting constructor from a LapsCollector instance. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Copies the LapsCollector. Starts the stopwatch. + * Post-conditions: is_running() if no error occur. + * + * Remark: The LapsCollector is copied and owned by the stopwatch. + */ + explicit stopwatch( + laps_collector const& acc, + system::error_code & ec + ) : + start_(duration::zero()), + running_(false), + laps_collector_(acc) + { + start(ec); + } +#endif + + /** + * Not starting constructor from a LapsCollector instance. + * + * Effects: Copies the LapsCollector. Don't starts the stopwatch. + * Post-conditions: ! is_running() if no error occur. + * + * Remark: The LapsCollector is copied and owned by the stopwatch. + */ + stopwatch( + laps_collector const& acc, + const dont_start_t& + ) : + start_(duration::zero()), + running_(false), + laps_collector_(acc) + { + } + + /** + * Destructor. + * + * Effects: Do nothing. + */ + ~stopwatch() BOOST_NOEXCEPT + { + } + + /** + * Restart the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: As if stop(); start() were called, but ensuring that the start time is the same as the stop time. + * + * Post-conditions: is_running() if no error occur. + */ + void restart() + { + time_point tmp = clock::now(); + + if (is_running()) + { + laps_collector_.store(tmp - start_); + } + else + { + running_ = true; + } + start_ = tmp; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Restart the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: As if stop(); start() were called, but ensuring that the start time is the same as the stop time. + * + * Post-conditions: is_running() if no error occur. + */ + void restart( + system::error_code & ec + ) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + if (is_running()) + { + laps_collector_.store(tmp - start_); + } + else + { + running_ = true; + } + start_ = tmp; + } +#endif + + /** + * Start the stopwatch. + * + * Effects: Memorize the current time. + * + * Post-conditions: is_running(). + */ + void start() + { + start_ = clock::now(); + running_ = true; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Start the stopwatch. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Memorize the current time. + * + * Post-conditions: @c is_running() if no error occur. + */ + void start( + system::error_code & ec + ) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + start_ = tmp; + running_ = true; + } +#endif + + /** + * Start the stopwatch. + * + * Requires: is_running(). + * Effects: Stores the elapsed time since start time into the LapCollector. + * + * Throws: Any exception that the LapCollector can throw. + * + * Post-conditions: !is_running() if no error occur. + */ + void stop() + { + if (is_running()) + { + laps_collector_.store(clock::now() - start_); + start_ = time_point(duration::zero()); + running_ = false; + } + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Start the stopwatch. + * + * Requires: is_running(). + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * Effects: Stores the elapsed time since start time into the LapCollector if no internal error occurs. + * + * Throws: Any exception that the LapCollector can Throw. + * + * Post-conditions: !is_running() if no error occur. + */ + void stop( + system::error_code & ec + ) + { + if (is_running()) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + laps_collector_.store(tmp - start_); + start_ = time_point(duration::zero()); + running_ = false; + } + } +#endif + + /** + * States if the Stopwatch is running. + */ + bool is_running() const { + return running_; + } + + /** + * Elapsed time getter for the current lap. + * + * Returns: the elapsed time since the last start if no internal error occur. + * + */ + duration elapsed_current_lap() const + { + if (is_running()) + { + return clock::now() - start_; + } + else + { + return duration::zero(); + } + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Elapsed time getter for the current lap. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * + * Returns: the elapsed time since the start if no internal error occur. + * + */ + duration elapsed_current_lap( + system::error_code & ec + ) const + { + if (is_running()) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return duration::zero(); + + return tmp - start_; + } else + { + return duration::zero(); + } + } +#endif + + /** + * Elapsed time getter. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * + * Returns: the elapsed time since the start if no internal error occur. + * + */ + duration elapsed() const + { + return laps_collector_.elapsed()+elapsed_current_lap(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + /** + * Elapsed time getter. + * + * Effects: Assign the error code if any internal error occur while retrieving the current time. + * + * Returns: the elapsed time since the start if no internal error occur. + * + */ + duration elapsed( + system::error_code & ec + ) const + { + duration tmp = elapsed_current_lap(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return duration::zero(); + return laps_collector_.elapsed() + tmp; + } +#endif + /** + * Elapsed time for the last lap. + * + * Returns: the elapsed time of the last lap. + * + */ + + duration last() const + { + return laps_collector_.last(); + } + /** + * Resets the stopwatch. + * + * Effects: Resets the LapCollector. + * + * Post-conditions: !is_running() if no error occur. + * + */ + void reset() + { + + laps_collector_.reset(); + running_ = false; + start_ = time_point(duration::zero()); + } + + /** + * LapsCollector getter. + * + * Returns: the LapCollector instance. + * + */ + laps_collector const& get_laps_collector() BOOST_NOEXCEPT + { + return laps_collector_; + } + + /** + * Useful typedef for scoped run + */ + typedef stopwatch_runner<stopwatch<Clock, LapsCollector> > + scoped_run; + /** + * Useful typedef for scoped stop + */ + typedef stopwatch_stopper<stopwatch<Clock, LapsCollector> > + scoped_stop; + + private: + time_point start_; + bool running_; + laps_collector laps_collector_; + }; + + } // namespace chrono +} // namespace boost + +#endif // header diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/stopwatch_scoped.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/stopwatch_scoped.hpp new file mode 100644 index 0000000000..836d0a9552 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/stopwatch_scoped.hpp @@ -0,0 +1,142 @@ +// boost/chrono/stopwatches/stopwatch_scoped.hpp ------------------------------------------------------------// +// Copyright 2009-2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_STOPWATCH_SCOPED_HPP +#define BOOST_CHRONO_STOPWATCHES_STOPWATCH_SCOPED_HPP + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/chrono.hpp> +#include <boost/chrono/detail/system.hpp> + +namespace boost +{ + namespace chrono + { + + //--------------------------------------------------------------------------------------// + template<class Stopwatch> + class stopwatch_runner + { + public: + typedef Stopwatch stopwatch; + stopwatch_runner(stopwatch & a) : + stopwatch_(a) + { + stopwatch_.start(); + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + stopwatch_runner(stopwatch & a, system::error_code & ec) : + stopwatch_(a) + { + stopwatch_.start(ec); + } +#endif + ~stopwatch_runner() + { + stopwatch_.stop(); + } + private: + stopwatch& stopwatch_; + stopwatch_runner();//= delete; + stopwatch_runner(const stopwatch_runner&); // = delete; + stopwatch_runner& operator=(const stopwatch_runner&); // = delete; + + }; + + //--------------------------------------------------------------------------------------// + template<class Stopwatch> + class stopwatch_stopper + { + public: + typedef Stopwatch stopwatch; + stopwatch_stopper(stopwatch & a) : + stopwatch_(a) + { + stopwatch_.stop(); + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + stopwatch_stopper(stopwatch & a, system::error_code & ec) : + stopwatch_(a) + { + stopwatch_.stop(ec); + } +#endif + ~stopwatch_stopper() + { + stopwatch_.start(); + } + private: + stopwatch& stopwatch_; + stopwatch_stopper();//= delete; + stopwatch_stopper(const stopwatch_stopper&); // = delete; + stopwatch_stopper& operator=(const stopwatch_stopper&); // = delete; + + }; + + //--------------------------------------------------------------------------------------// + template<class Stopwatch> + class stopwatch_suspender + { + public: + typedef Stopwatch stopwatch; + stopwatch_suspender(stopwatch & a) : + stopwatch_(a) + { + stopwatch_.suspend(); + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + stopwatch_suspender(stopwatch & a, system::error_code & ec) : + stopwatch_(a) + { + stopwatch_.suspend(ec); + } +#endif + + ~stopwatch_suspender() + { + stopwatch_.resume(); + } + private: + stopwatch& stopwatch_; + stopwatch_suspender(); // = delete; + stopwatch_suspender(const stopwatch_suspender&); // = delete; + stopwatch_suspender& operator=(const stopwatch_suspender&); // = delete; + }; + + //--------------------------------------------------------------------------------------// + template<class Stopwatch> + class stopwatch_resumer + { + public: + typedef Stopwatch stopwatch; + stopwatch_resumer(stopwatch & a) : + stopwatch_(a) + { + stopwatch_.resume(); + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + stopwatch_resumer(stopwatch & a, system::error_code & ec) : + stopwatch_(a) + { + stopwatch_.resume(ec); + } +#endif + ~stopwatch_resumer() + { + stopwatch_.suspend(); + } + private: + stopwatch& stopwatch_; + stopwatch_resumer(); // = delete; + stopwatch_resumer(const stopwatch_resumer&); // = delete; + stopwatch_resumer& operator=(const stopwatch_resumer&); // = delete; + }; + + } // namespace chrono +} // namespace boost + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/strict_stopwatch.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/strict_stopwatch.hpp new file mode 100644 index 0000000000..ceb0be66da --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/strict_stopwatch.hpp @@ -0,0 +1,115 @@ +// boost/chrono/stopwatches/strict_stopwatch.hpp ------------------------------------------------------------// +// Copyright 2011 Vicente J. Botet Escriba +// Copyright (c) Microsoft Corporation 2014 +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_STRICT_STOPWATCH__HPP +#define BOOST_CHRONO_STOPWATCHES_STRICT_STOPWATCH__HPP + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/chrono.hpp> +#include <boost/chrono/detail/system.hpp> +#include <boost/chrono/thread_clock.hpp> +#include <boost/chrono/process_cpu_clocks.hpp> +#include <utility> + +namespace boost +{ + namespace chrono + { + + /** + * This class provides the simpler stopwatch which is just able to give the elapsed time since its construction. + */ + template<typename Clock=high_resolution_clock> + class strict_stopwatch + { + public: + typedef Clock clock; + typedef typename Clock::duration duration; + typedef typename Clock::time_point time_point; + typedef typename Clock::rep rep; + typedef typename Clock::period period; + BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady; + + + strict_stopwatch() : + start_(clock::now()) + { + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit strict_stopwatch(system::error_code & ec) : + start_(duration::zero()) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec)) + { + if (ec) + { + return; + } + } + start_ = tmp; + } +#endif + + ~strict_stopwatch() BOOST_NOEXCEPT + { + } + + duration elapsed() + { + return clock::now() - start_; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + duration elapsed(system::error_code & ec) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec)) + { + if (ec) + return duration::zero(); + } + return tmp - start_; + } +#endif + /** + * States if the Stopwatch is running. + */ + bool is_running() const { + return true; + } + private: + time_point start_; + strict_stopwatch(const strict_stopwatch&); // = delete; + strict_stopwatch& operator=(const strict_stopwatch&); // = delete; + }; + + typedef strict_stopwatch<system_clock> system_strict_stopwatch; +#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY + typedef strict_stopwatch<steady_clock> steady_strict_stopwatch; +#endif + typedef strict_stopwatch<high_resolution_clock> high_resolution_strict_stopwatch; + +#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS) + typedef strict_stopwatch<process_real_cpu_clock> process_real_cpu_strict_stopwatch; +#if ! BOOST_OS_WINDOWS || BOOST_PLAT_WINDOWS_DESKTOP + typedef strict_stopwatch<process_user_cpu_clock> process_user_cpu_strict_stopwatch; + typedef strict_stopwatch<process_system_cpu_clock> process_system_cpu_strict_stopwatch; + typedef strict_stopwatch<process_cpu_clock> process_cpu_strict_stopwatch; +#endif +#endif + +#if defined(BOOST_CHRONO_HAS_THREAD_CLOCK) + typedef strict_stopwatch<thread_clock> thread_strict_stopwatch; +#endif + + + } // namespace chrono +} // namespace boost + +#endif diff --git a/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/suspendable_stopwatch.hpp b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/suspendable_stopwatch.hpp new file mode 100644 index 0000000000..5af8e948f6 --- /dev/null +++ b/contrib/restricted/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/suspendable_stopwatch.hpp @@ -0,0 +1,334 @@ +// boost/chrono/stopwatches/suspendable_stopwatch.hpp ------------------------------------------------------------// +// Copyright 2011 Vicente J. Botet Escriba +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/libs/chrono/stopwatches for documentation. + +#ifndef BOOST_CHRONO_STOPWATCHES_SUSPENDABLE_STOPWATCH__HPP +#define BOOST_CHRONO_STOPWATCHES_SUSPENDABLE_STOPWATCH__HPP + +#include <boost/chrono/config.hpp> + +#include <boost/chrono/stopwatches/stopwatch_scoped.hpp> +#include <boost/chrono/stopwatches/collectors/no_memory.hpp> // default laps_collector +#include <boost/chrono/stopwatches/dont_start.hpp> +#include <boost/chrono/detail/system.hpp> +#include <boost/chrono/system_clocks.hpp> +#include <utility> + +namespace boost +{ + namespace chrono + { + + template<typename Clock=high_resolution_clock, typename LapsCollector=no_memory<typename Clock::duration> > + class suspendable_stopwatch + { + public: + typedef LapsCollector laps_collector; + typedef Clock clock; + typedef typename Clock::duration duration; + typedef typename Clock::time_point time_point; + typedef typename Clock::rep rep; + typedef typename Clock::period period; + BOOST_STATIC_CONSTEXPR bool is_steady = Clock::is_steady; + + suspendable_stopwatch() : + start_(duration::zero()), + running_(false), + suspended_(false), + laps_collector_(), + partial_(duration::zero()) + { + start(); + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit suspendable_stopwatch( + system::error_code & ec + ) : + start_(duration::zero()), + running_(false), + suspended_(false), + laps_collector_(), + partial_(duration::zero()) + { + start(ec); + } +#endif + + explicit suspendable_stopwatch( + const dont_start_t& + ) : + start_(duration::zero()), + running_(false), + suspended_(false), + laps_collector_(), + partial_(duration::zero()) + { + } + + explicit suspendable_stopwatch( + laps_collector const& acc + ) : + start_(duration::zero()), + running_(false), + suspended_(false), + laps_collector_(acc), + partial_(duration::zero()) + { + start(); + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + explicit suspendable_stopwatch( + laps_collector const& acc, + system::error_code & ec + ) : + start_(duration::zero()), + running_(false), + suspended_(false), + laps_collector_(acc), + partial_(duration::zero()) + { + start(ec); + } +#endif + + suspendable_stopwatch( + laps_collector const& acc, + const dont_start_t& + ) : + start_(duration::zero()), + running_(false), + suspended_(false), + laps_collector_(acc), + partial_(duration::zero()) + { + } + + ~suspendable_stopwatch() + { + stop(); + } + + void restart() + { + time_point tmp = clock::now(); + + if (running_) + { + partial_ += tmp - start_; + laps_collector_.store(partial_); + partial_ = duration::zero(); + } + else + { + running_ = true; + } + start_ = tmp; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + void restart(system::error_code & ec) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + if (running_) + { + partial_ += tmp - start_; + laps_collector_.store(partial_); + partial_ = duration::zero(); + } + else + { + running_ = true; + } + start_ = tmp; + } +#endif + + void start() + { + start_ = clock::now();; + partial_ = duration::zero(); + running_ = true; + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + void start(system::error_code & ec) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + partial_ = duration::zero(); + start_ = tmp; + running_ = true; + } +#endif + + void stop() + { + partial_ += clock::now() - start_; + laps_collector_.store(partial_); + start_ = time_point(duration::zero()); + running_ = false; + suspended_ = false; + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + void stop(system::error_code & ec) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + partial_ += tmp - start_; + laps_collector_.store(partial_); + start_ = time_point(duration::zero()); + running_ = false; + suspended_ = false; + } +#endif + + void suspend() + { + if (is_running()) + { + if (!suspended_) + { + partial_ += clock::now() - start_; + suspended_ = true; + } + } + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + void suspend(system::error_code & ec) + { + if (is_running()) + { + if (!suspended_) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + partial_ += tmp - start_; + suspended_ = true; + } + else + { + ec.clear(); + } + } else + { + ec.clear(); + } + } +#endif + + void resume() + { + if (suspended_) + { + start_ = clock::now(); + suspended_ = false; + } + } + +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + void resume(system::error_code & ec) + { + if (suspended_) + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return; + + start_ = tmp; + suspended_ = false; + } else + { + ec.clear(); + } + } +#endif + + bool is_running() const { + return running_; + } + bool is_suspended() const { + return suspended_; + } + + duration elapsed() const + { + if (is_running()) + { + if (suspended_) { + return partial_; + } + else + { + return partial_ + clock::now() - start_; + } + } else + { + return duration::zero(); + } + } +#if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING + duration elapsed(system::error_code & ec) const + { + if (is_running()) + { + if (suspended_) { + return partial_; + } + else + { + time_point tmp = clock::now(ec); + if (!BOOST_CHRONO_IS_THROWS(ec) && ec) return duration::zero(); + + return partial_ + tmp - start_; + } + } else + { + return duration::zero(); + } + } +#endif + + void reset( + ) + { + laps_collector_.reset(); + running_ = false; + suspended_ = false; + partial_ = duration::zero(); + start_ = time_point(duration::zero()); + } + + laps_collector const& get_laps_collector() + { + return laps_collector_; + } + + + typedef stopwatch_runner<suspendable_stopwatch<Clock, LapsCollector> > + scoped_run; + typedef stopwatch_stopper<suspendable_stopwatch<Clock, LapsCollector> > + scoped_stop; + typedef stopwatch_suspender<suspendable_stopwatch<Clock, LapsCollector> > + scoped_suspend; + typedef stopwatch_resumer<suspendable_stopwatch<Clock, LapsCollector> > + scoped_resume; + private: + time_point start_; + bool running_; + bool suspended_; + laps_collector laps_collector_; + duration partial_; + }; + + } // namespace chrono +} // namespace boost + +#endif |