diff options
| author | alexv-smirnov <[email protected]> | 2023-03-15 19:59:12 +0300 |
|---|---|---|
| committer | alexv-smirnov <[email protected]> | 2023-03-15 19:59:12 +0300 |
| commit | 056bb284ccf8dd6793ec3a54ffa36c4fb2b9ad11 (patch) | |
| tree | 4740980126f32e3af7937ba0ca5f83e59baa4ab0 /contrib/restricted/boost/timer | |
| parent | 269126dcced1cc8b53eb4398b4a33e5142f10290 (diff) | |
add library/cpp/actors, ymake build to ydb oss export
Diffstat (limited to 'contrib/restricted/boost/timer')
11 files changed, 1145 insertions, 0 deletions
diff --git a/contrib/restricted/boost/timer/.yandex_meta/devtools.copyrights.report b/contrib/restricted/boost/timer/.yandex_meta/devtools.copyrights.report new file mode 100644 index 00000000000..7a3bfe908dd --- /dev/null +++ b/contrib/restricted/boost/timer/.yandex_meta/devtools.copyrights.report @@ -0,0 +1,107 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits +# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files +# $ # user comments +# $ +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP COPYRIGHT_SERVICE_LABEL 1f37a51e40512369e14c67203766141f +BELONGS ya.make + License text: + // Copyright Beman Dawes 1994-2006, 2011 + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + src/cpu_timer.cpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL 214ba99e016d97577b7672e9e87aa6fa +BELONGS ya.make + License text: + // Copyright Beman Dawes 2007, 2011 + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + src/auto_timers_construction.cpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL 26c31cb23da28e487c480a209fc8f691 +BELONGS ya.make + License text: + // Copyright Beman Dawes 2003, 2006, 2011 + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/timer/config.hpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL 2eac2a7e626c242b613fa68d3431bb40 +BELONGS ya.make + License text: + // Copyright Beman Dawes 1994-2007, 2011 + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/timer/timer.hpp [3:3] + +KEEP COPYRIGHT_SERVICE_LABEL 7ae8b16c39fc36f50a0a218368b84a03 +BELONGS ya.make + License text: + // Copyright Beman Dawes 1994-99. 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) + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/progress.hpp [3:5] + include/boost/timer.hpp [3:5] + include/boost/timer/progress_display.hpp [2:5] + +KEEP COPYRIGHT_SERVICE_LABEL da89dc42ada008b813c4236faeffa262 +BELONGS ya.make + License text: + // Copyright Beman Dawes 1994-99. + // Copyright Peter Dimov 2019. + // Distributed under the Boost Software License, Version 1.0. + // (http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: COPYRIGHT_SERVICE_LABEL + Score : 100.00 + Match type : COPYRIGHT + Files with this license: + include/boost/timer/progress_display.hpp [2:5] diff --git a/contrib/restricted/boost/timer/.yandex_meta/devtools.licenses.report b/contrib/restricted/boost/timer/.yandex_meta/devtools.licenses.report new file mode 100644 index 00000000000..531469596d6 --- /dev/null +++ b/contrib/restricted/boost/timer/.yandex_meta/devtools.licenses.report @@ -0,0 +1,113 @@ +# File format ($ symbol means the beginning of a line): +# +# $ # this message +# $ # ======================= +# $ # comments (all commentaries should starts with some number of spaces and # symbol) +# $ IGNORE_FILES {file1.ext1} {file2.ext2} - (optional) ignore listed files when generating license macro and credits +# $ RENAME {original license id} TO {new license id} # user comments - (optional) use {new license id} instead {original license id} in ya.make files +# $ # user comments +# $ +# ${action} {license id} {license text hash} +# $BELONGS ./ya/make/file/relative/path/1/ya.make ./ya/make/2/ya.make +# ${all_file_action} filename +# $ # user commentaries (many lines) +# $ generated description - files with this license, license text... (some number of lines that starts with some number of spaces, do not modify) +# ${action} {license spdx} {license text hash} +# $BELONGS ./ya/make/file/relative/path/3/ya.make +# ${all_file_action} filename +# $ # user commentaries +# $ generated description +# $ ... +# +# You can modify action, all_file_action and add commentaries +# Available actions: +# keep - keep license in contrib and use in credits +# skip - skip license +# remove - remove all files with this license +# rename - save license text/links into licenses texts file, but not store SPDX into LINCENSE macro. You should store correct license id into devtools.license.spdx.txt file +# +# {all file action} records will be generated when license text contains filename that exists on filesystem (in contrib directory) +# We suppose that that files can contain some license info +# Available all file actions: +# FILE_IGNORE - ignore file (do nothing) +# FILE_INCLUDE - include all file data into licenses text file +# ======================= + +KEEP BSL-1.0 2bf0d9fd1287367814514ba593d6b189 +BELONGS ya.make + License text: + // (http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 44.00 + Match type : REFERENCE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/timer/progress_display.hpp [5:5] + +KEEP BSL-1.0 67c315f84c9f7fe64ea5034b22a3514e +BELONGS ya.make + License text: + // Distributed under the Boost Software License, Version 1.0. + // See http://www.boost.org/LICENSE_1_0.txt) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + src/auto_timers_construction.cpp [5:6] + +KEEP BSL-1.0 d7f87ea2cced5bb8dd0a81e515f54c30 +BELONGS ya.make + License text: + // 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) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + src/cpu_timer.cpp [5:6] + +KEEP BSL-1.0 da2a87ccf5ae416e33c8d6bfe78baa14 +BELONGS ya.make + License text: + // Distributed under the Boost Software License, Version 1.0. + // See http://www.boost.org/LICENSE_1_0.txt + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/timer/config.hpp [5:6] + include/boost/timer/timer.hpp [5:6] + +KEEP BSL-1.0 e03c043ca7052925e34194f3fe2631e4 +BELONGS ya.make + License text: + // Distributed under the Boost Software License, Version 1.0. + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/timer/progress_display.hpp [4:4] + +KEEP BSL-1.0 e6a3c462b8c40b8d1b8ef9a1bfe334ea +BELONGS ya.make + License text: + // Copyright Beman Dawes 1994-99. 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) + Scancode info: + Original SPDX id: BSL-1.0 + Score : 100.00 + Match type : NOTICE + Links : http://www.boost.org/LICENSE_1_0.txt, http://www.boost.org/users/license.html, https://spdx.org/licenses/BSL-1.0 + Files with this license: + include/boost/progress.hpp [3:5] + include/boost/timer.hpp [3:5] diff --git a/contrib/restricted/boost/timer/.yandex_meta/licenses.list.txt b/contrib/restricted/boost/timer/.yandex_meta/licenses.list.txt new file mode 100644 index 00000000000..d1779bdbb75 --- /dev/null +++ b/contrib/restricted/boost/timer/.yandex_meta/licenses.list.txt @@ -0,0 +1,56 @@ +====================BSL-1.0==================== +// Copyright Beman Dawes 1994-99. 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 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==================== +// (http://www.boost.org/LICENSE_1_0.txt) + + +====================BSL-1.0==================== +// Distributed under the Boost Software License, Version 1.0. + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 1994-2006, 2011 + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 1994-2007, 2011 + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 1994-99. 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==================== +// Copyright Beman Dawes 2003, 2006, 2011 + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 2007, 2011 + + +====================COPYRIGHT==================== +// Copyright Beman Dawes 1994-99. +// Copyright Peter Dimov 2019. +// Distributed under the Boost Software License, Version 1.0. +// (http://www.boost.org/LICENSE_1_0.txt) diff --git a/contrib/restricted/boost/timer/include/boost/progress.hpp b/contrib/restricted/boost/timer/include/boost/progress.hpp new file mode 100644 index 00000000000..be6ec6ad002 --- /dev/null +++ b/contrib/restricted/boost/timer/include/boost/progress.hpp @@ -0,0 +1,145 @@ +// boost progress.hpp header file ------------------------------------------// + +// Copyright Beman Dawes 1994-99. 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/timer for documentation. + +// Revision History +// 1 Dec 01 Add leading progress display strings (suggested by Toon Knapen) +// 20 May 01 Introduce several static_casts<> to eliminate warning messages +// (Fixed by Beman, reported by Herve Bronnimann) +// 12 Jan 01 Change to inline implementation to allow use without library +// builds. See docs for more rationale. (Beman Dawes) +// 22 Jul 99 Name changed to .hpp +// 16 Jul 99 Second beta +// 6 Jul 99 Initial boost version + +#ifndef BOOST_PROGRESS_HPP +#define BOOST_PROGRESS_HPP + +#include <boost/config/header_deprecated.hpp> +BOOST_HEADER_DEPRECATED( "the facilities in <boost/timer/timer.hpp> or <boost/timer/progress_display.hpp>" ) + +#include <boost/timer.hpp> +#include <boost/noncopyable.hpp> +#include <boost/cstdint.hpp> // for uintmax_t +#include <iostream> // for ostream, cout, etc +#include <string> // for string + +namespace boost { + +// progress_timer ----------------------------------------------------------// + +// A progress_timer behaves like a timer except that the destructor displays +// an elapsed time message at an appropriate place in an appropriate form. + +class progress_timer : public timer, private noncopyable +{ + + public: + explicit progress_timer( std::ostream & os = std::cout ) + // os is hint; implementation may ignore, particularly in embedded systems + : timer(), noncopyable(), m_os(os) {} + ~progress_timer() + { + // A) Throwing an exception from a destructor is a Bad Thing. + // B) The progress_timer destructor does output which may throw. + // C) A progress_timer is usually not critical to the application. + // Therefore, wrap the I/O in a try block, catch and ignore all exceptions. + try + { + // use istream instead of ios_base to workaround GNU problem (Greg Chicares) + std::istream::fmtflags old_flags = m_os.setf( std::istream::fixed, + std::istream::floatfield ); + std::streamsize old_prec = m_os.precision( 2 ); + m_os << elapsed() << " s\n" // "s" is System International d'Unites std + << std::endl; + m_os.flags( old_flags ); + m_os.precision( old_prec ); + } + + catch (...) {} // eat any exceptions + } // ~progress_timer + + private: + std::ostream & m_os; +}; + + +// progress_display --------------------------------------------------------// + +// progress_display displays an appropriate indication of +// progress at an appropriate place in an appropriate form. + +// NOTE: (Jan 12, 2001) Tried to change unsigned long to boost::uintmax_t, but +// found some compilers couldn't handle the required conversion to double. +// Reverted to unsigned long until the compilers catch up. + +class progress_display : private noncopyable +{ + public: + explicit progress_display( unsigned long expected_count_, + std::ostream & os = std::cout, + const std::string & s1 = "\n", //leading strings + const std::string & s2 = "", + const std::string & s3 = "" ) + // os is hint; implementation may ignore, particularly in embedded systems + : noncopyable(), m_os(os), m_s1(s1), m_s2(s2), m_s3(s3) { restart(expected_count_); } + + void restart( unsigned long expected_count_ ) + // Effects: display appropriate scale + // Postconditions: count()==0, expected_count()==expected_count_ + { + _count = _next_tic_count = _tic = 0; + _expected_count = expected_count_; + + m_os << m_s1 << "0% 10 20 30 40 50 60 70 80 90 100%\n" + << m_s2 << "|----|----|----|----|----|----|----|----|----|----|" + << std::endl // endl implies flush, which ensures display + << m_s3; + if ( !_expected_count ) _expected_count = 1; // prevent divide by zero + } // restart + + unsigned long operator+=( unsigned long increment ) + // Effects: Display appropriate progress tic if needed. + // Postconditions: count()== original count() + increment + // Returns: count(). + { + if ( (_count += increment) >= _next_tic_count ) { display_tic(); } + return _count; + } + + unsigned long operator++() { return operator+=( 1 ); } + unsigned long count() const { return _count; } + unsigned long expected_count() const { return _expected_count; } + + private: + std::ostream & m_os; // may not be present in all imps + const std::string m_s1; // string is more general, safer than + const std::string m_s2; // const char *, and efficiency or size are + const std::string m_s3; // not issues + + unsigned long _count, _expected_count, _next_tic_count; + unsigned int _tic; + void display_tic() + { + // use of floating point ensures that both large and small counts + // work correctly. static_cast<>() is also used several places + // to suppress spurious compiler warnings. + unsigned int tics_needed = static_cast<unsigned int>((static_cast<double>(_count) + / static_cast<double>(_expected_count)) * 50.0); + do { m_os << '*' << std::flush; } while ( ++_tic < tics_needed ); + _next_tic_count = + static_cast<unsigned long>((_tic/50.0) * static_cast<double>(_expected_count)); + if ( _count == _expected_count ) { + if ( _tic < 51 ) m_os << '*'; + m_os << std::endl; + } + } // display_tic +}; + +} // namespace boost + +#endif // BOOST_PROGRESS_HPP diff --git a/contrib/restricted/boost/timer/include/boost/timer.hpp b/contrib/restricted/boost/timer/include/boost/timer.hpp new file mode 100644 index 00000000000..f3ddb41f6c1 --- /dev/null +++ b/contrib/restricted/boost/timer/include/boost/timer.hpp @@ -0,0 +1,75 @@ +// boost timer.hpp header file ---------------------------------------------// + +// Copyright Beman Dawes 1994-99. 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/timer for documentation. + +// Revision History +// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (JMaddock) +// 12 Jan 01 Change to inline implementation to allow use without library +// builds. See docs for more rationale. (Beman Dawes) +// 25 Sep 99 elapsed_max() and elapsed_min() added (John Maddock) +// 16 Jul 99 Second beta +// 6 Jul 99 Initial boost version + +#ifndef BOOST_TIMER_HPP +#define BOOST_TIMER_HPP + +#include <boost/config/header_deprecated.hpp> +BOOST_HEADER_DEPRECATED( "the facilities in <boost/timer/timer.hpp>" ) + +#include <boost/config.hpp> +#include <ctime> +#include <boost/limits.hpp> + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::clock_t; using ::clock; } +# endif + + +namespace boost { + +// timer -------------------------------------------------------------------// + +// A timer object measures elapsed time. + +// It is recommended that implementations measure wall clock rather than CPU +// time since the intended use is performance measurement on systems where +// total elapsed time is more important than just process or CPU time. + +// Warnings: The maximum measurable elapsed time may well be only 596.5+ hours +// due to implementation limitations. The accuracy of timings depends on the +// accuracy of timing information provided by the underlying platform, and +// this varies a great deal from platform to platform. + +class timer +{ + public: + timer() { _start_time = std::clock(); } // postcondition: elapsed()==0 +// timer( const timer& src ); // post: elapsed()==src.elapsed() +// ~timer(){} +// timer& operator=( const timer& src ); // post: elapsed()==src.elapsed() + void restart() { _start_time = std::clock(); } // post: elapsed()==0 + double elapsed() const // return elapsed time in seconds + { return double(std::clock() - _start_time) / CLOCKS_PER_SEC; } + + double elapsed_max() const // return estimated maximum value for elapsed() + // Portability warning: elapsed_max() may return too high a value on systems + // where std::clock_t overflows or resets at surprising values. + { + return (double((std::numeric_limits<std::clock_t>::max)()) + - double(_start_time)) / double(CLOCKS_PER_SEC); + } + + double elapsed_min() const // return minimum value for elapsed() + { return double(1)/double(CLOCKS_PER_SEC); } + + private: + std::clock_t _start_time; +}; // timer + +} // namespace boost + +#endif // BOOST_TIMER_HPP diff --git a/contrib/restricted/boost/timer/include/boost/timer/config.hpp b/contrib/restricted/boost/timer/include/boost/timer/config.hpp new file mode 100644 index 00000000000..a7c3d9d20e8 --- /dev/null +++ b/contrib/restricted/boost/timer/include/boost/timer/config.hpp @@ -0,0 +1,69 @@ +// boost/timer/config.hpp -----------------------------------------------------------// + +// Copyright Beman Dawes 2003, 2006, 2011 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// See http://www.boost.org/libs/timer for documentation. + +#ifndef BOOST_TIMER_CONFIG_HPP +#define BOOST_TIMER_CONFIG_HPP + +#include <boost/config.hpp> + +#include <boost/system/api_config.hpp> + +// This header implements separate compilation features as described in +// http://www.boost.org/more/separate_compilation.html + +// enable dynamic or static linking as requested --------------------------------------// + +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TIMER_DYN_LINK) +# if defined(BOOST_TIMER_SOURCE) +# define BOOST_TIMER_DECL BOOST_SYMBOL_EXPORT +# else +# define BOOST_TIMER_DECL BOOST_SYMBOL_IMPORT +# endif +#else +# define BOOST_TIMER_DECL +#endif + +// enable automatic library variant selection ----------------------------------------// + +#if !defined(BOOST_TIMER_SOURCE) && !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_TIMER_NO_LIB) +// +// Set the name of our library, this will get undef'ed by auto_link.hpp +// once it's done with it: +// +#define BOOST_LIB_NAME boost_timer +// +// If we're importing code from a dll, then tell auto_link.hpp about it: +// +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_TIMER_DYN_LINK) +# define BOOST_DYN_LINK +#endif +// +// And include the header that does the work: +// +#include <boost/config/auto_link.hpp> + +// We also need to autolink to the Chrono library; even though +// it's not used in the interface, and no Chrono header is included, +// it's used in the implementation and is necessary in order to link + +#if !defined(BOOST_CHRONO_NO_LIB) + +#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK) +# define BOOST_DYN_LINK +#endif + +#define BOOST_LIB_NAME boost_chrono + +#include <boost/config/auto_link.hpp> + +#endif // !defined(BOOST_CHRONO_NO_LIB) + +#endif // auto-linking disabled + +#endif // BOOST_TIMER_CONFIG_HPP diff --git a/contrib/restricted/boost/timer/include/boost/timer/progress_display.hpp b/contrib/restricted/boost/timer/include/boost/timer/progress_display.hpp new file mode 100644 index 00000000000..f40a219c7cc --- /dev/null +++ b/contrib/restricted/boost/timer/include/boost/timer/progress_display.hpp @@ -0,0 +1,90 @@ + +// Copyright Beman Dawes 1994-99. +// Copyright Peter Dimov 2019. +// Distributed under the Boost Software License, Version 1.0. +// (http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/timer for documentation. + +#ifndef BOOST_TIMER_PROGRESS_DISPLAY_HPP_INCLUDED +#define BOOST_TIMER_PROGRESS_DISPLAY_HPP_INCLUDED + +#include <boost/noncopyable.hpp> +#include <iostream> // for ostream, cout, etc +#include <string> // for string + +namespace boost { +namespace timer { + +// progress_display --------------------------------------------------------// + +// progress_display displays an appropriate indication of +// progress at an appropriate place in an appropriate form. + +class progress_display : private noncopyable +{ + public: + explicit progress_display( unsigned long expected_count_, + std::ostream & os = std::cout, + const std::string & s1 = "\n", //leading strings + const std::string & s2 = "", + const std::string & s3 = "" ) + // os is hint; implementation may ignore, particularly in embedded systems + : noncopyable(), m_os(os), m_s1(s1), m_s2(s2), m_s3(s3) { restart(expected_count_); } + + void restart( unsigned long expected_count_ ) + // Effects: display appropriate scale + // Postconditions: count()==0, expected_count()==expected_count_ + { + _count = _next_tic_count = _tic = 0; + _expected_count = expected_count_; + + m_os << m_s1 << "0% 10 20 30 40 50 60 70 80 90 100%\n" + << m_s2 << "|----|----|----|----|----|----|----|----|----|----|" + << std::endl // endl implies flush, which ensures display + << m_s3; + if ( !_expected_count ) _expected_count = 1; // prevent divide by zero + } // restart + + unsigned long operator+=( unsigned long increment ) + // Effects: Display appropriate progress tic if needed. + // Postconditions: count()== original count() + increment + // Returns: count(). + { + if ( (_count += increment) >= _next_tic_count ) { display_tic(); } + return _count; + } + + unsigned long operator++() { return operator+=( 1 ); } + unsigned long count() const { return _count; } + unsigned long expected_count() const { return _expected_count; } + + private: + std::ostream & m_os; // may not be present in all imps + const std::string m_s1; // string is more general, safer than + const std::string m_s2; // const char *, and efficiency or size are + const std::string m_s3; // not issues + + unsigned long _count, _expected_count, _next_tic_count; + unsigned int _tic; + void display_tic() + { + // use of floating point ensures that both large and small counts + // work correctly. static_cast<>() is also used several places + // to suppress spurious compiler warnings. + unsigned int tics_needed = static_cast<unsigned int>((static_cast<double>(_count) + / static_cast<double>(_expected_count)) * 50.0); + do { m_os << '*' << std::flush; } while ( ++_tic < tics_needed ); + _next_tic_count = + static_cast<unsigned long>((_tic/50.0) * static_cast<double>(_expected_count)); + if ( _count == _expected_count ) { + if ( _tic < 51 ) m_os << '*'; + m_os << std::endl; + } + } // display_tic +}; + +} // namespace timer +} // namespace boost + +#endif // BOOST_TIMER_PROGRESS_DISPLAY_HPP_INCLUDED diff --git a/contrib/restricted/boost/timer/include/boost/timer/timer.hpp b/contrib/restricted/boost/timer/include/boost/timer/timer.hpp new file mode 100644 index 00000000000..8bf996081d0 --- /dev/null +++ b/contrib/restricted/boost/timer/include/boost/timer/timer.hpp @@ -0,0 +1,129 @@ +// boost/timer/timer.hpp -------------------------------------------------------------// + +// Copyright Beman Dawes 1994-2007, 2011 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_TIMER_TIMER_HPP +#define BOOST_TIMER_TIMER_HPP + +#include <boost/timer/config.hpp> +#include <boost/cstdint.hpp> +#include <string> +#include <cstring> +#include <ostream> + +#include <boost/config/abi_prefix.hpp> // must be the last #include + +# if defined(_MSC_VER) +# pragma warning(push) // Save warning settings +# pragma warning(disable : 4251) // disable warning: class 'std::basic_string<_Elem,_Traits,_Ax>' +# endif // needs to have dll-interface... + +//--------------------------------------------------------------------------------------// + +namespace boost +{ +namespace timer +{ + class cpu_timer; + class auto_cpu_timer; + + typedef boost::int_least64_t nanosecond_type; + + struct cpu_times + { + nanosecond_type wall; + nanosecond_type user; + nanosecond_type system; + + void clear() { wall = user = system = 0; } + }; + + const short default_places = 6; + + BOOST_TIMER_DECL + std::string format(const cpu_times& times, short places, const std::string& format); + + BOOST_TIMER_DECL + std::string format(const cpu_times& times, short places = default_places); + +// cpu_timer -------------------------------------------------------------------------// + + class BOOST_TIMER_DECL cpu_timer + { + public: + + // constructor + cpu_timer() BOOST_NOEXCEPT { start(); } + + // observers + bool is_stopped() const BOOST_NOEXCEPT { return m_is_stopped; } + cpu_times elapsed() const BOOST_NOEXCEPT; // does not stop() + std::string format(short places, const std::string& format) const + { return ::boost::timer::format(elapsed(), places, format); } + std::string format(short places = default_places) const + { return ::boost::timer::format(elapsed(), places); } + // actions + void start() BOOST_NOEXCEPT; + void stop() BOOST_NOEXCEPT; + void resume() BOOST_NOEXCEPT; + + private: + cpu_times m_times; + bool m_is_stopped; + }; + +// auto_cpu_timer --------------------------------------------------------------------// + + class BOOST_TIMER_DECL auto_cpu_timer : public cpu_timer + { + public: + + // Explicit defaults for os are not provided to avoid including <iostream>, which has + // high costs even when the standard streams are not actually used. Explicit defaults + // for format are not provided to avoid order-of-dynamic-initialization issues with a + // std::string. + + explicit auto_cpu_timer(short places = default_places); // #1 + auto_cpu_timer(short places, const std::string& format); // #2 + explicit auto_cpu_timer(const std::string& format); // #3 + auto_cpu_timer(std::ostream& os, short places, + const std::string& format) // #4 + : m_places(places), m_os(&os), m_format(format) + { start(); } + explicit auto_cpu_timer(std::ostream& os, short places = default_places); // #5 + auto_cpu_timer(std::ostream& os, const std::string& format) // #6 + : m_places(default_places), m_os(&os), m_format(format) + { start(); } + + ~auto_cpu_timer(); + + // observers + // not particularly useful to users, but allow testing of constructor + // postconditions and ease specification of other functionality without resorting + // to "for exposition only" private members. + std::ostream& ostream() const { return *m_os; } + short places() const { return m_places; } + const std::string& format_string() const { return m_format; } + + // actions + void report(); + + private: + short m_places; + std::ostream* m_os; // stored as ptr so compiler can generate operator= + std::string m_format; + }; + +} // namespace timer +} // namespace boost + +# if defined(_MSC_VER) +# pragma warning(pop) // restore warning settings. +# endif + +#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas + +#endif // BOOST_TIMER_TIMER_HPP diff --git a/contrib/restricted/boost/timer/src/auto_timers_construction.cpp b/contrib/restricted/boost/timer/src/auto_timers_construction.cpp new file mode 100644 index 00000000000..b23b54674f7 --- /dev/null +++ b/contrib/restricted/boost/timer/src/auto_timers_construction.cpp @@ -0,0 +1,46 @@ +// boost auto_timers_construction.cpp ------------------------------------------------// + +// Copyright Beman Dawes 2007, 2011 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/timer for documentation. + +//--------------------------------------------------------------------------------------// + +// These constructors are in a separate file so that this translation unit will +// not be linked in except when one of the constructors is actually used. This +// is important since header <iostream> is required, and it incurs the cost of +// the standard stream objects even if they are not used. + +//--------------------------------------------------------------------------------------// + +// define BOOST_TIMER_SOURCE so that <boost/timer/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_TIMER_SOURCE + +#include <boost/timer/timer.hpp> +#include <iostream> + +namespace +{ + // CAUTION: must be identical to same constant in cpu_timer.cpp + const std::string default_fmt(" %ws wall, %us user + %ss system = %ts CPU (%p%)\n"); +} + +namespace boost +{ + namespace timer + { + auto_cpu_timer::auto_cpu_timer(short places) // #1 + : m_places(places), m_os(&std::cout), m_format(default_fmt) { start(); } + + auto_cpu_timer::auto_cpu_timer(short places, const std::string& format) // #2 + : m_places(places), m_os(&std::cout), m_format(format) { start(); } + + auto_cpu_timer::auto_cpu_timer(const std::string& format) // #3 + : m_places(default_places), m_os(&std::cout), m_format(format) { start(); } + + } // namespace timer +} // namespace boost diff --git a/contrib/restricted/boost/timer/src/cpu_timer.cpp b/contrib/restricted/boost/timer/src/cpu_timer.cpp new file mode 100644 index 00000000000..36b2ac40726 --- /dev/null +++ b/contrib/restricted/boost/timer/src/cpu_timer.cpp @@ -0,0 +1,268 @@ +// boost cpu_timer.cpp ---------------------------------------------------------------// + +// Copyright Beman Dawes 1994-2006, 2011 + +// 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/timer for documentation. + +//--------------------------------------------------------------------------------------// + +// define BOOST_TIMER_SOURCE so that <boost/timer/config.hpp> knows +// the library is being built (possibly exporting rather than importing code) +#define BOOST_TIMER_SOURCE + +#include <boost/timer/timer.hpp> +#include <boost/chrono/chrono.hpp> +#include <boost/io/ios_state.hpp> +#include <boost/throw_exception.hpp> +#include <boost/cerrno.hpp> +#include <boost/predef.h> +#include <cstring> +#include <sstream> +#include <cassert> + +# if defined(BOOST_WINDOWS_API) +# include <windows.h> +# elif defined(BOOST_POSIX_API) +# include <unistd.h> +# include <sys/times.h> +# else +# error unknown API +# endif + +using boost::timer::nanosecond_type; +using boost::timer::cpu_times; + +namespace +{ + + void show_time(const cpu_times& times, + std::ostream& os, const std::string& fmt, short places) + // NOTE WELL: Will truncate least-significant digits to LDBL_DIG, which may + // be as low as 10, although will be 15 for many common platforms. + { + if (places > 9) + places = 9; + else if (places < 0) + places = boost::timer::default_places; + + boost::io::ios_flags_saver ifs(os); + boost::io::ios_precision_saver ips(os); + os.setf(std::ios_base::fixed, std::ios_base::floatfield); + os.precision(places); + + const double sec = 1000000000.0L; + nanosecond_type total = times.system + times.user; + double wall_sec = static_cast<double>(times.wall) / sec; + double total_sec = static_cast<double>(total) / sec; + + for (const char* format = fmt.c_str(); *format; ++format) + { + if (*format != '%' || !*(format+1) || !std::strchr("wustp", *(format+1))) + os << *format; // anything except % followed by a valid format character + // gets sent to the output stream + else + { + ++format; + switch (*format) + { + case 'w': + os << wall_sec; + break; + case 'u': + os << static_cast<double>(times.user) / sec; + break; + case 's': + os << static_cast<double>(times.system) / sec; + break; + case 't': + os << total_sec; + break; + case 'p': + os.precision(1); + if (wall_sec > 0.001L && total_sec > 0.001L) + os << (total_sec/wall_sec) * 100.0; + else + os << "n/a"; + os.precision(places); + break; + } + } + } + } + +# if defined(BOOST_POSIX_API) + + boost::int_least64_t tick_factor_() + { + boost::int_least64_t tf = ::sysconf( _SC_CLK_TCK ); + if( tf <= 0 ) return -1; + + tf = INT64_C(1000000000) / tf; // compute factor + if( tf == 0 ) tf = -1; + + return tf; + } + + boost::int_least64_t tick_factor() // multiplier to convert ticks + // to nanoseconds; -1 if unknown + { + static boost::int_least64_t tf = tick_factor_(); + return tf; + } + +# endif + + void get_cpu_times(boost::timer::cpu_times& current) + { + boost::chrono::duration<boost::int64_t, boost::nano> + x (boost::chrono::high_resolution_clock::now().time_since_epoch()); + current.wall = x.count(); + +# if defined(BOOST_WINDOWS_API) + +# if BOOST_PLAT_WINDOWS_DESKTOP || defined(__CYGWIN__) + FILETIME creation, exit; + if (::GetProcessTimes(::GetCurrentProcess(), &creation, &exit, + (LPFILETIME)¤t.system, (LPFILETIME)¤t.user)) + { + current.user *= 100; // Windows uses 100 nanosecond ticks + current.system *= 100; + } + else +# endif + { + current.system = current.user = boost::timer::nanosecond_type(-1); + } +# else + tms tm; + clock_t c = ::times(&tm); + if (c == static_cast<clock_t>(-1)) // error + { + current.system = current.user = boost::timer::nanosecond_type(-1); + } + else + { + current.system = boost::timer::nanosecond_type(tm.tms_stime + tm.tms_cstime); + current.user = boost::timer::nanosecond_type(tm.tms_utime + tm.tms_cutime); + boost::int_least64_t factor; + if ((factor = tick_factor()) != -1) + { + current.user *= factor; + current.system *= factor; + } + else + { + current.user = current.system = boost::timer::nanosecond_type(-1); + } + } +# endif + } + + // CAUTION: must be identical to same constant in auto_timers_construction.cpp + const std::string default_fmt(" %ws wall, %us user + %ss system = %ts CPU (%p%)\n"); + +} // unnamed namespace + +namespace boost +{ + namespace timer + { + // format ------------------------------------------------------------------------// + + BOOST_TIMER_DECL + std::string format(const cpu_times& times, short places, const std::string& fmt) + { + std::stringstream ss; + ss.exceptions(std::ios_base::badbit | std::ios_base::failbit); + show_time(times, ss, fmt, places); + return ss.str(); + } + + BOOST_TIMER_DECL + std::string format(const cpu_times& times, short places) + { + return format(times, places, default_fmt); + } + + // cpu_timer ---------------------------------------------------------------------// + + void cpu_timer::start() BOOST_NOEXCEPT + { + m_is_stopped = false; + get_cpu_times(m_times); + } + + void cpu_timer::stop() BOOST_NOEXCEPT + { + if (is_stopped()) + return; + m_is_stopped = true; + + cpu_times current; + get_cpu_times(current); + m_times.wall = (current.wall - m_times.wall); + m_times.user = (current.user - m_times.user); + m_times.system = (current.system - m_times.system); + } + + cpu_times cpu_timer::elapsed() const BOOST_NOEXCEPT + { + if (is_stopped()) + return m_times; + cpu_times current; + get_cpu_times(current); + current.wall -= m_times.wall; + current.user -= m_times.user; + current.system -= m_times.system; + return current; + } + + void cpu_timer::resume() BOOST_NOEXCEPT + { + if (is_stopped()) + { + cpu_times current (m_times); + start(); + m_times.wall -= current.wall; + m_times.user -= current.user; + m_times.system -= current.system; + } + } + + // auto_cpu_timer ----------------------------------------------------------------// + + auto_cpu_timer::auto_cpu_timer(std::ostream& os, short places) // #5 + : m_places(places), m_os(&os), m_format(default_fmt) + { + start(); + } + + void auto_cpu_timer::report() + { + show_time(elapsed(), ostream(), format_string(), places()); + } + + auto_cpu_timer::~auto_cpu_timer() + { + if (!is_stopped()) + { + stop(); // the sooner we stop(), the better +#ifndef BOOST_NO_EXCEPTIONS + try + { +#endif + report(); +#ifndef BOOST_NO_EXCEPTIONS + } + catch (...) // eat any exceptions + { + } +#endif + } + } + + } // namespace timer +} // namespace boost diff --git a/contrib/restricted/boost/timer/ya.make b/contrib/restricted/boost/timer/ya.make new file mode 100644 index 00000000000..e21ee8b2701 --- /dev/null +++ b/contrib/restricted/boost/timer/ya.make @@ -0,0 +1,47 @@ +# Generated by devtools/yamaker from nixpkgs 22.05. + +LIBRARY() + +LICENSE(BSL-1.0) + +LICENSE_TEXTS(.yandex_meta/licenses.list.txt) + +OWNER( + g:cpp-contrib + g:taxi-common +) + +VERSION(1.81.0) + +ORIGINAL_SOURCE(https://github.com/boostorg/timer/archive/boost-1.81.0.tar.gz) + +PEERDIR( + contrib/restricted/boost/chrono + contrib/restricted/boost/config + contrib/restricted/boost/core + contrib/restricted/boost/io + contrib/restricted/boost/predef + contrib/restricted/boost/system + contrib/restricted/boost/throw_exception +) + +ADDINCL( + GLOBAL contrib/restricted/boost/timer/include +) + +NO_COMPILER_WARNINGS() + +NO_UTIL() + +IF (DYNAMIC_BOOST) + CFLAGS( + GLOBAL -DBOOST_TIMER_DYN_LINK + ) +ENDIF() + +SRCS( + src/auto_timers_construction.cpp + src/cpu_timer.cpp +) + +END() |
