diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/timer | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/timer')
19 files changed, 1401 insertions, 0 deletions
diff --git a/src/boost/libs/timer/build/Jamfile.v2 b/src/boost/libs/timer/build/Jamfile.v2 new file mode 100644 index 00000000..195cbc17 --- /dev/null +++ b/src/boost/libs/timer/build/Jamfile.v2 @@ -0,0 +1,27 @@ +# Boost Timer Library Build Jamfile + +# (C) Copyright Beman Dawes 2002, 2006, 2011 + +# Distributed under the Boost Software License, Version 1.0. +# See www.boost.org/LICENSE_1_0.txt + +# See library home page at http://www.boost.org/libs/timer + +project boost/timer + : source-location ../src + : requirements + <library>/boost/chrono//boost_chrono + : usage-requirements # pass these requirement to dependants (i.e. users) + <link>shared:<define>BOOST_TIMER_DYN_LINK=1 + <link>static:<define>BOOST_TIMER_STATIC_LINK=1 + ; + +SOURCES = auto_timers_construction cpu_timer ; + +lib boost_timer + : $(SOURCES).cpp + : <link>shared:<define>BOOST_TIMER_DYN_LINK=1 + <link>static:<define>BOOST_TIMER_STATIC_LINK=1 + ; + +boost-install boost_timer ; diff --git a/src/boost/libs/timer/example/auto_cpu_timer_example.cpp b/src/boost/libs/timer/example/auto_cpu_timer_example.cpp new file mode 100644 index 00000000..02213e3b --- /dev/null +++ b/src/boost/libs/timer/example/auto_cpu_timer_example.cpp @@ -0,0 +1,19 @@ +// auto_cpu_timer_example.cpp ------------------------------------------------------// + +// Copyright Beman Dawes 2006 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +#include <boost/timer/timer.hpp> +#include <cmath> + +int main() +{ + boost::timer::auto_cpu_timer t; + + for ( long i = 0; i < 100000000; ++i ) + std::sqrt( 123.456L ); // burn some time + + return 0; +} diff --git a/src/boost/libs/timer/example/timex.cpp b/src/boost/libs/timer/example/timex.cpp new file mode 100644 index 00000000..f0597ef9 --- /dev/null +++ b/src/boost/libs/timer/example/timex.cpp @@ -0,0 +1,47 @@ +// timex: timed execution program ------------------------------------------// + +// Copyright Beman Dawes 2007 + +// 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. + +#include <boost/timer/timer.hpp> +#include <cstdlib> +#include <string> +#include <iostream> + +int main( int argc, char * argv[] ) +{ + if ( argc == 1 ) + { + std::cout << "invoke: timex [-v] command [args...]\n" + " command will be executed and timings displayed\n" + " -v option causes command and args to be displayed\n"; + return 1; + } + + std::string s; + + bool verbose = false; + if ( argc > 1 && *argv[1] == '-' && *(argv[1]+1) == 'v' ) + { + verbose = true; + ++argv; + --argc; + } + + for ( int i = 1; i < argc; ++i ) + { + if ( i > 1 ) s += ' '; + s += argv[i]; + } + + if ( verbose ) + { std::cout << "command: \"" << s.c_str() << "\"\n"; } + + boost::timer::auto_cpu_timer t(" %ws elapsed wall-clock time\n"); + + return std::system( s.c_str() ); +} diff --git a/src/boost/libs/timer/index.html b/src/boost/libs/timer/index.html new file mode 100644 index 00000000..8680aee2 --- /dev/null +++ b/src/boost/libs/timer/index.html @@ -0,0 +1,14 @@ +<html> +<head> +<meta http-equiv="refresh" content="0; URL=doc/index.html"> +</head> +<body> +Automatic redirection failed, please go to <a href="doc/index.html">doc/index.html</a>. +<hr> +<p>© Copyright Beman Dawes, 2003, 2011</p> +<p> Distributed under the Boost Software +License, Version 1.0.</p> +<p> See <a href="http://www.boost.org/LICENSE_1_0.txt"> +www.boost.org/LICENSE_1_0.txt</a></p> +</body> +</html> diff --git a/src/boost/libs/timer/meta/libraries.json b/src/boost/libs/timer/meta/libraries.json new file mode 100644 index 00000000..4120233e --- /dev/null +++ b/src/boost/libs/timer/meta/libraries.json @@ -0,0 +1,14 @@ +{ + "key": "timer", + "name": "Timer", + "authors": [ + "Beman Dawes" + ], + "description": "Event timer, progress timer, and progress display classes.", + "category": [ + "Miscellaneous" + ], + "maintainers": [ + "Beman Dawes <bdawes -at- acm.org>" + ] +} diff --git a/src/boost/libs/timer/src/auto_timers_construction.cpp b/src/boost/libs/timer/src/auto_timers_construction.cpp new file mode 100644 index 00000000..b23b5467 --- /dev/null +++ b/src/boost/libs/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/src/boost/libs/timer/src/cpu_timer.cpp b/src/boost/libs/timer/src/cpu_timer.cpp new file mode 100644 index 00000000..82a8d7b1 --- /dev/null +++ b/src/boost/libs/timer/src/cpu_timer.cpp @@ -0,0 +1,267 @@ +// 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; +using boost::system::error_code; + +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() // multiplier to convert ticks + // to nanoseconds; -1 if unknown + { + static boost::int_least64_t tick_factor = 0; + if (!tick_factor) + { + if ((tick_factor = ::sysconf(_SC_CLK_TCK)) <= 0) + tick_factor = -1; + else + { + tick_factor = INT64_C(1000000000) / tick_factor; // compute factor + if (!tick_factor) + tick_factor = -1; + } + } + return tick_factor; + } +# 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/src/boost/libs/timer/test/Jamfile.v2 b/src/boost/libs/timer/test/Jamfile.v2 new file mode 100644 index 00000000..154cbb7c --- /dev/null +++ b/src/boost/libs/timer/test/Jamfile.v2 @@ -0,0 +1,33 @@ +# Boost Timer Library test Jamfile + +# 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 library home page at http://www.boost.org/libs/timer + +import testing ; + +path-constant parent : .. ; # so that inspect will start in boost-root/libs/timer + # when run from another directory, such as boost-root/status + +project + : requirements + <library>/boost/timer//boost_timer + ; + +run ../example/auto_cpu_timer_example.cpp : : : <test-info>always_show_run_output ; + +run cpu_timer_info.cpp : : : <test-info>always_show_run_output ; +run cpu_timer_test.cpp : : : <test-info>always_show_run_output ; + +run ../example/timex.cpp : echo "Hello, world" : : <test-info>always_show_run_output ; + +compile original_timer_test.cpp ; +run chrono_conflict_test.cpp /boost/chrono//boost_chrono : : : <link>static ; + +run progress_display_test.cpp ; + +run /boost/tools/inspect//inspect/<variant>release : $(parent) -text -brief : : <test-info>always_show_run_output : inspect ; +explicit inspect ; diff --git a/src/boost/libs/timer/test/chrono_conflict_test.cpp b/src/boost/libs/timer/test/chrono_conflict_test.cpp new file mode 100644 index 00000000..8d5386b8 --- /dev/null +++ b/src/boost/libs/timer/test/chrono_conflict_test.cpp @@ -0,0 +1,16 @@ +// Copyright 2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// Check that using Chrono and Timer in the same program does +// not cause link errors. + + +#include <boost/chrono.hpp> +#include <boost/timer/timer.hpp> + +int main() +{ + boost::chrono::steady_clock::now(); + boost::timer::cpu_timer cpt; +} diff --git a/src/boost/libs/timer/test/cpu_timer_info.cpp b/src/boost/libs/timer/test/cpu_timer_info.cpp new file mode 100644 index 00000000..11e722c8 --- /dev/null +++ b/src/boost/libs/timer/test/cpu_timer_info.cpp @@ -0,0 +1,75 @@ +// boost cpu_timer_info.cpp ----------------------------------------------------------// + +// Copyright Beman Dawes 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. + +#include <boost/timer/timer.hpp> +#include <boost/chrono/chrono.hpp> +#include <boost/detail/lightweight_main.hpp> +#include <cstdlib> // for atol() +#include <iostream> +#include <locale> + +using boost::timer::nanosecond_type; +using boost::timer::cpu_times; +using boost::timer::cpu_timer; +using boost::timer::auto_cpu_timer; +using std::cout; using std::endl; + +int cpp_main( int argc, char * argv[] ) +{ + cout << '\n'; + cout << "For cpu_times.wall, the underlying clock " + << (boost::chrono::high_resolution_clock::is_steady + ? "is steady. " + : "is not steady. " + ) + << "Steady clocks are defined by C++11 as clocks for which values " + "of time_point never decrease as physical time advances and for " + "which values of time_point advance at a steady rate relative to " + "real time. That is, the clock may not be adjusted.\n\n"; + + cpu_times start_time; + start_time.clear(); + cpu_times current_time; + + { + cpu_timer cpu; + cout << "measure boost::timer::cpu_timer resolution for user time..." + << endl; + for (int i = 0; i < 3; ++i) + { + cpu.start(); + start_time = cpu.elapsed(); + current_time.user = start_time.user; + while (current_time.user == start_time.user) + { + current_time = cpu.elapsed(); + } + cout << current_time.user - start_time.user << "ns\n"; + } + } + + { + cpu_timer cpu; + cout << "measure boost::timer::cpu_timer resolution for wall-clock time..." + << endl; + for (int i = 0; i < 100; ++i) + { + cpu.start(); + start_time.wall = cpu.elapsed().wall; + current_time.wall = start_time.wall; + while (current_time.wall == start_time.wall) + { + current_time.wall = cpu.elapsed().wall; + } + cout << current_time.wall - start_time.wall << "ns "; + } + } + return 0; +} + diff --git a/src/boost/libs/timer/test/cpu_timer_test.cpp b/src/boost/libs/timer/test/cpu_timer_test.cpp new file mode 100644 index 00000000..bf9784db --- /dev/null +++ b/src/boost/libs/timer/test/cpu_timer_test.cpp @@ -0,0 +1,227 @@ +// boost timer_test.cpp --------------------------------------------------------------// + +// Copyright Beman Dawes 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. + +#include <boost/timer/timer.hpp> +#include <boost/detail/lightweight_main.hpp> +#include <boost/detail/lightweight_test.hpp> +#include <cstdlib> // for atol() +#include <iostream> +#include <string> +#include <ctime> + +using std::string; +using std::cout; +using std::endl; +using boost::timer::default_places; +using boost::timer::nanosecond_type; +using boost::timer::cpu_times; +using boost::timer::format; +using boost::timer::cpu_timer; +using boost::timer::auto_cpu_timer; + +namespace +{ + void unit_test() + { + cout << "unit test..." << endl; + + string default_format(" %ws wall, %us user + %ss system = %ts CPU (%p%)\n"); + + // each constructor + auto_cpu_timer t1; + BOOST_TEST(!t1.is_stopped()); + // the following, and similar below, are giving false failures on MinGW/gcc + // so comment them out for now + //BOOST_TEST(&t1.ostream() == &cout); + BOOST_TEST_EQ(t1.places(), default_places); + BOOST_TEST_EQ(t1.format_string(), default_format); + t1.stop(); + BOOST_TEST(t1.is_stopped()); + auto_cpu_timer t1a(t1); + BOOST_TEST(t1a.is_stopped()); + BOOST_TEST_EQ(t1a.elapsed().wall, t1.elapsed().wall); + BOOST_TEST_EQ(t1a.elapsed().user, t1.elapsed().user); + BOOST_TEST_EQ(t1a.elapsed().system, t1.elapsed().system); + //BOOST_TEST(&t1a.ostream() == &cout); + BOOST_TEST_EQ(t1a.places(), default_places); + BOOST_TEST_EQ(t1a.format_string(), default_format); + + auto_cpu_timer t1b; + BOOST_TEST(!t1b.is_stopped()); + t1b = t1; + BOOST_TEST(t1b.is_stopped()); + BOOST_TEST_EQ(t1b.elapsed().wall, t1.elapsed().wall); + BOOST_TEST_EQ(t1b.elapsed().user, t1.elapsed().user); + BOOST_TEST_EQ(t1b.elapsed().system, t1.elapsed().system); + //BOOST_TEST(&t1b.ostream() == &cout); + BOOST_TEST_EQ(t1b.places(), default_places); + BOOST_TEST_EQ(t1b.format_string(), default_format); + + auto_cpu_timer t2(1); + BOOST_TEST(!t2.is_stopped()); + //BOOST_TEST(&t2.ostream() == &cout); + BOOST_TEST_EQ(t2.places(), 1); + BOOST_TEST_EQ(t2.format_string(), default_format); + + auto_cpu_timer t3("foo"); + BOOST_TEST(!t3.is_stopped()); + //BOOST_TEST(&t3.ostream() == &cout); + BOOST_TEST_EQ(t3.places(), default_places); + BOOST_TEST_EQ(t3.format_string(), string("foo")); + + auto_cpu_timer t4(1, "foo"); + BOOST_TEST(!t4.is_stopped()); + //BOOST_TEST(&t4.ostream() == &cout); + BOOST_TEST_EQ(t4.places(), 1); + BOOST_TEST_EQ(t4.format_string(), string("foo")); + + auto_cpu_timer t5(std::cerr); + BOOST_TEST(!t5.is_stopped()); + BOOST_TEST(&t5.ostream() == &std::cerr); + BOOST_TEST_EQ(t5.places(), default_places); + BOOST_TEST_EQ(t5.format_string(), default_format); + + auto_cpu_timer t6(std::cerr, 1); + BOOST_TEST(!t6.is_stopped()); + BOOST_TEST(&t6.ostream() == &std::cerr); + BOOST_TEST_EQ(t6.places(), 1); + BOOST_TEST_EQ(t6.format_string(), default_format); + + auto_cpu_timer t7(std::cerr, "foo"); + BOOST_TEST(!t7.is_stopped()); + BOOST_TEST(&t7.ostream() == &std::cerr); + BOOST_TEST_EQ(t7.places(), default_places); + BOOST_TEST_EQ(t7.format_string(), string("foo")); + + auto_cpu_timer t8(std::cerr, 1, "foo"); + BOOST_TEST(!t8.is_stopped()); + BOOST_TEST(&t8.ostream() == &std::cerr); + BOOST_TEST_EQ(t8.places(), 1); + BOOST_TEST_EQ(t8.format_string(), string("foo")); + + t1.stop(); + t1a.stop(); + t1b.stop(); + t2.stop(); + t3.stop(); + t4.stop(); + t5.stop(); + t6.stop(); + t7.stop(); + t8.stop(); + + cout << " unit test complete" << endl; + } + + void format_test() + { + cout << "format test..." << endl; + + cpu_times times; + times.wall = 5123456789LL; + times.user = 2123456789LL; + times.system = 1234567890LL; + + cout << " times.wall is " << times.wall << '\n'; + cout << " times.user is " << times.user << '\n'; + cout << " times.system is " << times.system << '\n'; + cout << " user+system is " << times.user + times.system << '\n'; + cout << " format(times, 9) output: " << format(times, 9); + + BOOST_TEST_EQ(format(times, 9), + string(" 5.123456789s wall, 2.123456789s user + 1.234567890s system = 3.358024679s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 8), + string(" 5.12345679s wall, 2.12345679s user + 1.23456789s system = 3.35802468s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 7), + string(" 5.1234568s wall, 2.1234568s user + 1.2345679s system = 3.3580247s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 6), + string(" 5.123457s wall, 2.123457s user + 1.234568s system = 3.358025s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 5), + string(" 5.12346s wall, 2.12346s user + 1.23457s system = 3.35802s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 4), + string(" 5.1235s wall, 2.1235s user + 1.2346s system = 3.3580s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 3), + string(" 5.123s wall, 2.123s user + 1.235s system = 3.358s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 2), + string(" 5.12s wall, 2.12s user + 1.23s system = 3.36s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 1), + string(" 5.1s wall, 2.1s user + 1.2s system = 3.4s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 0), + string(" 5s wall, 2s user + 1s system = 3s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, 10), + string(" 5.123456789s wall, 2.123456789s user + 1.234567890s system = 3.358024679s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times, -1), + string(" 5.123457s wall, 2.123457s user + 1.234568s system = 3.358025s CPU (65.5%)\n")); + BOOST_TEST_EQ(format(times), + string(" 5.123457s wall, 2.123457s user + 1.234568s system = 3.358025s CPU (65.5%)\n")); + + BOOST_TEST_EQ(format(times, 5, " %w, %u, %s, %t, %%p%"), + string(" 5.12346, 2.12346, 1.23457, 3.35802, %65.5%")); + + BOOST_TEST_EQ(format(times, 5, "boo"), string("boo")); + + cout << " format test complete" << endl; + } + + void std_c_consistency_test() + { + cout << "C library consistency test..." << endl; + + // This test is designed to account for C timer resolution and for the possibility + // that another active process may take up a lot of time. + + cpu_timer t; // calls start(), so ensures any cpu_timer dll loaded + std::time(0); // ensure any system dll's loaded + + std::time_t stop_time, start_time = std::time(0); + + // wait until the time() clock ticks + while (std::time(0) == start_time) {} + + // start both timers + start_time = std::time(0); + t.start(); + + // wait until the time() clock ticks again + while (std::time(0) == start_time) {} + + // stop both timers + stop_time = std::time(0); + t.stop(); + + cout << " std::time() elapsed is " << (stop_time - start_time) * 1.0L << " seconds\n"; + cout << " cpu_timer wall elapsed is " << t.elapsed().wall / 1000000000.0L << " seconds\n"; + cout << " The two clocks whose elapsed time is compared by this test are started\n" + " and stopped one right after the other. If the operating system suspends\n" + " the process in the interim, the test may fail. Thus no single failure\n" + " of this test is meaningful.\n"; + + // These tests allow lots of fuzz to reduce false positives + BOOST_TEST(t.elapsed().wall / 1000000000.0L > (stop_time - start_time) * 0.75L); + BOOST_TEST(t.elapsed().wall / 1000000000.0L < (stop_time - start_time) * 1.25L); + + cout << " C library consistency test complete" << endl; + } + + +} // unnamed namespace + +//--------------------------------------------------------------------------------------// + +int cpp_main(int, char *[]) +{ + cout << "---------- timer_test ----------\n"; + + unit_test(); + format_test(); + std_c_consistency_test(); + + return ::boost::report_errors(); +} + diff --git a/src/boost/libs/timer/test/msvc10/chrono_dll/chrono_dll.vcxproj b/src/boost/libs/timer/test/msvc10/chrono_dll/chrono_dll.vcxproj new file mode 100644 index 00000000..5b1a0491 --- /dev/null +++ b/src/boost/libs/timer/test/msvc10/chrono_dll/chrono_dll.vcxproj @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{C88697D9-587C-4649-AA39-8819A96A2A12}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>chrono_dll</RootNamespace> + <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CHRONO_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <PostBuildEvent> + <Message> + </Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHRONO_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <PostBuildEvent> + <Message> + </Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\..\..\chrono\src\chrono.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\system_dll\system_dll.vcxproj"> + <Project>{443dd1e8-4d52-4323-8280-a2320df7ef6d}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/timer/test/msvc10/common.props b/src/boost/libs/timer/test/msvc10/common.props new file mode 100644 index 00000000..76dea392 --- /dev/null +++ b/src/boost/libs/timer/test/msvc10/common.props @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ImportGroup Label="PropertySheets" /> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup /> + <ItemDefinitionGroup> + <ClCompile> + <AdditionalIncludeDirectories>../../../../..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>BOOST_ALL_NO_LIB;BOOST_ALL_DYN_LINK;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <WarningLevel>Level4</WarningLevel> + </ClCompile> + <PostBuildEvent> + <Command>"$(TargetDir)\$(TargetName).exe"</Command> + </PostBuildEvent> + <PostBuildEvent> + <Message>Executing test $(TargetName).exe...</Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup /> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/timer/test/msvc10/cpu_timer_test/cpu_timer_test.vcxproj b/src/boost/libs/timer/test/msvc10/cpu_timer_test/cpu_timer_test.vcxproj new file mode 100644 index 00000000..638ff28e --- /dev/null +++ b/src/boost/libs/timer/test/msvc10/cpu_timer_test/cpu_timer_test.vcxproj @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{955C9C33-5364-4F02-9D59-65657E8DFBA9}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>cpu_timer_test</RootNamespace> + <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Console</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\cpu_timer_test.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\chrono_dll\chrono_dll.vcxproj"> + <Project>{c88697d9-587c-4649-aa39-8819a96a2a12}</Project> + </ProjectReference> + <ProjectReference Include="..\system_dll\system_dll.vcxproj"> + <Project>{443dd1e8-4d52-4323-8280-a2320df7ef6d}</Project> + </ProjectReference> + <ProjectReference Include="..\timer_dll\timer_dll.vcxproj"> + <Project>{8a6cf2a1-c5f7-4119-b510-88b98197bcb2}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/timer/test/msvc10/system_dll/system_dll.vcxproj b/src/boost/libs/timer/test/msvc10/system_dll/system_dll.vcxproj new file mode 100644 index 00000000..595aa036 --- /dev/null +++ b/src/boost/libs/timer/test/msvc10/system_dll/system_dll.vcxproj @@ -0,0 +1,103 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{443DD1E8-4D52-4323-8280-A2320DF7EF6D}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>system_dll</RootNamespace> + <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;SYSTEM_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <PostBuildEvent> + <Message> + </Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;SYSTEM_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <PostBuildEvent> + <Message> + </Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\..\..\system\src\error_code.cpp" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/timer/test/msvc10/timer.sln b/src/boost/libs/timer/test/msvc10/timer.sln new file mode 100644 index 00000000..c70b5437 --- /dev/null +++ b/src/boost/libs/timer/test/msvc10/timer.sln @@ -0,0 +1,50 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "timer_dll", "timer_dll\timer_dll.vcxproj", "{8A6CF2A1-C5F7-4119-B510-88B98197BCB2}" + ProjectSection(ProjectDependencies) = postProject + {C88697D9-587C-4649-AA39-8819A96A2A12} = {C88697D9-587C-4649-AA39-8819A96A2A12} + {443DD1E8-4D52-4323-8280-A2320DF7EF6D} = {443DD1E8-4D52-4323-8280-A2320DF7EF6D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chrono_dll", "chrono_dll\chrono_dll.vcxproj", "{C88697D9-587C-4649-AA39-8819A96A2A12}" + ProjectSection(ProjectDependencies) = postProject + {443DD1E8-4D52-4323-8280-A2320DF7EF6D} = {443DD1E8-4D52-4323-8280-A2320DF7EF6D} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "system_dll", "system_dll\system_dll.vcxproj", "{443DD1E8-4D52-4323-8280-A2320DF7EF6D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpu_timer_test", "cpu_timer_test\cpu_timer_test.vcxproj", "{955C9C33-5364-4F02-9D59-65657E8DFBA9}" + ProjectSection(ProjectDependencies) = postProject + {8A6CF2A1-C5F7-4119-B510-88B98197BCB2} = {8A6CF2A1-C5F7-4119-B510-88B98197BCB2} + {C88697D9-587C-4649-AA39-8819A96A2A12} = {C88697D9-587C-4649-AA39-8819A96A2A12} + {443DD1E8-4D52-4323-8280-A2320DF7EF6D} = {443DD1E8-4D52-4323-8280-A2320DF7EF6D} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8A6CF2A1-C5F7-4119-B510-88B98197BCB2}.Debug|Win32.ActiveCfg = Debug|Win32 + {8A6CF2A1-C5F7-4119-B510-88B98197BCB2}.Debug|Win32.Build.0 = Debug|Win32 + {8A6CF2A1-C5F7-4119-B510-88B98197BCB2}.Release|Win32.ActiveCfg = Release|Win32 + {8A6CF2A1-C5F7-4119-B510-88B98197BCB2}.Release|Win32.Build.0 = Release|Win32 + {C88697D9-587C-4649-AA39-8819A96A2A12}.Debug|Win32.ActiveCfg = Debug|Win32 + {C88697D9-587C-4649-AA39-8819A96A2A12}.Debug|Win32.Build.0 = Debug|Win32 + {C88697D9-587C-4649-AA39-8819A96A2A12}.Release|Win32.ActiveCfg = Release|Win32 + {C88697D9-587C-4649-AA39-8819A96A2A12}.Release|Win32.Build.0 = Release|Win32 + {443DD1E8-4D52-4323-8280-A2320DF7EF6D}.Debug|Win32.ActiveCfg = Debug|Win32 + {443DD1E8-4D52-4323-8280-A2320DF7EF6D}.Debug|Win32.Build.0 = Debug|Win32 + {443DD1E8-4D52-4323-8280-A2320DF7EF6D}.Release|Win32.ActiveCfg = Release|Win32 + {443DD1E8-4D52-4323-8280-A2320DF7EF6D}.Release|Win32.Build.0 = Release|Win32 + {955C9C33-5364-4F02-9D59-65657E8DFBA9}.Debug|Win32.ActiveCfg = Debug|Win32 + {955C9C33-5364-4F02-9D59-65657E8DFBA9}.Debug|Win32.Build.0 = Debug|Win32 + {955C9C33-5364-4F02-9D59-65657E8DFBA9}.Release|Win32.ActiveCfg = Release|Win32 + {955C9C33-5364-4F02-9D59-65657E8DFBA9}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/boost/libs/timer/test/msvc10/timer_dll/timer_dll.vcxproj b/src/boost/libs/timer/test/msvc10/timer_dll/timer_dll.vcxproj new file mode 100644 index 00000000..229880e0 --- /dev/null +++ b/src/boost/libs/timer/test/msvc10/timer_dll/timer_dll.vcxproj @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{8A6CF2A1-C5F7-4119-B510-88B98197BCB2}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>timer_dll</RootNamespace> + <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v141</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="..\common.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TIMER_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <PostBuildEvent> + <Message> + </Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader> + </PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TIMER_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + </Link> + <PostBuildEvent> + <Command> + </Command> + </PostBuildEvent> + <PostBuildEvent> + <Message> + </Message> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\..\..\src\auto_timers_construction.cpp" /> + <ClCompile Include="..\..\..\src\cpu_timer.cpp" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\chrono_dll\chrono_dll.vcxproj"> + <Project>{c88697d9-587c-4649-aa39-8819a96a2a12}</Project> + </ProjectReference> + <ProjectReference Include="..\system_dll\system_dll.vcxproj"> + <Project>{443dd1e8-4d52-4323-8280-a2320df7ef6d}</Project> + </ProjectReference> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/boost/libs/timer/test/original_timer_test.cpp b/src/boost/libs/timer/test/original_timer_test.cpp new file mode 100644 index 00000000..c76c8ade --- /dev/null +++ b/src/boost/libs/timer/test/original_timer_test.cpp @@ -0,0 +1,89 @@ +// timer, job_timer, and progress_display sample program -------------------// + +// Copyright Beman Dawes 1998. 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 +// 12 Jan 01 Cut time to 1.0 secs to speed regression tests (Beman Dawes) +// 25 Sep 99 added elapsed_min() and elapsed_max() reporting +// 16 Jul 99 Second beta +// 6 Jul 99 Initial boost version + +#include <boost/progress.hpp> +#include <iostream> +#include <climits> + +using boost::timer; +using boost::progress_timer; +using boost::progress_display; +using std::cout; +using std::endl; + +int main() { + + timer t0; // used only for elapsed_max() and elapsed_min() + + cout << "timer::elapsed_min() reports " << t0.elapsed_min() << " seconds\n"; + cout << "timer::elapsed_max() reports " << t0.elapsed_max() + << " seconds, which is " << t0.elapsed_max()/3600.0 << " hours\n"; + + cout << "\nverify progress_display(0) doesn't divide by zero" << endl; + progress_display zero( 0 ); // verify 0 doesn't divide by zero + ++zero; + + long loops; + timer loop_timer; + const double time = 1.0; + + cout << "\ndetermine " << time << " second iteration count" << endl; + for ( loops = 0; loops < LONG_MAX + && loop_timer.elapsed() < time; ++loops ) {} + cout << loops << " iterations"<< endl; + + long i; + bool time_waster; // defeat [some] optimizers by storing result here + + progress_timer pt; + timer t1; + timer t4; + timer t5; + + cout << "\nburn about " << time << " seconds" << endl; + progress_display pd( loops ); + for ( i = loops; i--; ) + { time_waster = loop_timer.elapsed() < time; ++pd; } + + timer t2( t1 ); + timer t3; + t4 = t3; + t5.restart(); + + cout << "\nburn about " << time << " seconds again" << endl; + pd.restart( loops ); + for ( i = loops; i--; ) + { time_waster = loop_timer.elapsed() < time; ++pd; } + + if ( time_waster ) cout << ' '; // using time_waster quiets compiler warnings + progress_display pd2( 50, cout, "\nLead string 1 ", "Lead string 2 ", "Lead string 3 " ); + for ( ; pd2.count() < 50; ++pd2 ) {} + + cout << "\nt1 elapsed: " << t1.elapsed() << '\n'; + cout << "t2 elapsed: " << t2.elapsed() << '\n'; + cout << "t3 elapsed: " << t3.elapsed() << '\n'; + cout << "t4 elapsed: " << t4.elapsed() << '\n'; + cout << "t5 elapsed: " << t5.elapsed() << '\n'; + cout << "t1 and t2 should report the same times (very approximately " + << 2*time << " seconds).\n"; + cout << "t3, t4 and t5 should report about the same times,\n"; + cout << "and these should be about half the t1 and t2 times.\n"; + cout << "The following elapsed time should be slightly greater than t1." + << endl; + return 0; + } // main + + + + diff --git a/src/boost/libs/timer/test/progress_display_test.cpp b/src/boost/libs/timer/test/progress_display_test.cpp new file mode 100644 index 00000000..c591010a --- /dev/null +++ b/src/boost/libs/timer/test/progress_display_test.cpp @@ -0,0 +1,37 @@ + +// Copyright 2019 Peter Dimov. +// Distributed under the Boost Software License, Version 1.0. + +#include <boost/timer/progress_display.hpp> +#include <boost/core/lightweight_test.hpp> +#include <sstream> +#include <cstddef> + +int main() +{ + int n = 17; + + std::ostringstream os; + boost::timer::progress_display pd( n, os, "L1:", "L2:", "L3:" ); + + BOOST_TEST_EQ( os.str(), std::string( + "L1:0% 10 20 30 40 50 60 70 80 90 100%\n" + "L2:|----|----|----|----|----|----|----|----|----|----|\n" + "L3:" ) ); + + for( int i = 0; i < n; ++i ) + { + std::size_t m1 = os.str().size(); + ++pd; + std::size_t m2 = os.str().size(); + + BOOST_TEST_LE( m1, m2 ); + } + + BOOST_TEST_EQ( os.str(), std::string( + "L1:0% 10 20 30 40 50 60 70 80 90 100%\n" + "L2:|----|----|----|----|----|----|----|----|----|----|\n" + "L3:***************************************************\n" ) ); + + return boost::report_errors(); +} |