mirror of
https://github.com/boostorg/chrono.git
synced 2025-05-09 23:04:05 +00:00
Make Stopwatches a sub-module of Chrono.
This commit is contained in:
parent
f8d4923146
commit
b2b4636d92
8
README.md
Normal file
8
README.md
Normal file
@ -0,0 +1,8 @@
|
||||
Chrono
|
||||
======
|
||||
|
||||
Useful time utilities. C++11.
|
||||
|
||||
### License
|
||||
|
||||
Distributed under the [Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).
|
36
meta/libraries.json
Normal file
36
meta/libraries.json
Normal file
@ -0,0 +1,36 @@
|
||||
[
|
||||
{
|
||||
"key": "chrono",
|
||||
"name": "Chrono",
|
||||
"authors": [
|
||||
"Howard Hinnant",
|
||||
"Beman Dawes"
|
||||
"Vicente J. Botet Escriba"
|
||||
],
|
||||
"maintainers": [
|
||||
"Vicente J. Botet Escriba <vicente.botet -at- wanadoo.fr>"
|
||||
],
|
||||
"description":
|
||||
"Useful time utilities. C++11.",
|
||||
"std": [ "proposal" ],
|
||||
"category": [
|
||||
"Domain", "System"
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "chrono/stopwatch",
|
||||
"name": "Chrono.Stopwatch",
|
||||
"authors": [
|
||||
"Vicente J. Botet Escriba"
|
||||
],
|
||||
"maintainers": [
|
||||
"Vicente J. Botet Escriba <vicente.botet -at- wanadoo.fr>"
|
||||
],
|
||||
"description":
|
||||
"Useful stopclocks and stopwatches utilities.",
|
||||
"documentation": "stopwatches/",
|
||||
"category": [
|
||||
"Domain"
|
||||
]
|
||||
},
|
||||
]
|
145
stopwatches/test/Jamfile.v2
Normal file
145
stopwatches/test/Jamfile.v2
Normal file
@ -0,0 +1,145 @@
|
||||
# Boost Chrono Library test Jamfile
|
||||
|
||||
# Copyright Vicente J. Botet Escriba 2014
|
||||
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
# See library home page at http://www.boost.org/libs/chrono/stopwatch
|
||||
|
||||
import os ;
|
||||
import feature ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<target-os>freebsd:<linkflags>"-lrt"
|
||||
<target-os>linux:<linkflags>"-lrt -lpthread"
|
||||
<toolset>clang/<target-os>linux:<linkflags>"-lpthread"
|
||||
<toolset>pgi:<linkflags>"-lrt"
|
||||
#<threading>single:<define>BOOST_CHRONO_THREAD_DISABLED
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
<define>BOOST_CHRONO_USES_MPL_ASSERT
|
||||
<define>BOOST_SYSTEM_NO_DEPRECATED
|
||||
#<toolset>sun:<define>BOOST_COMMON_TYPE_DONT_USE_TYPEOF
|
||||
#<toolset>sun:<define>BOOST_TYPEOF_EMULATION
|
||||
<toolset>sun:<define>__typeof__=__typeof__
|
||||
<warnings>all
|
||||
<toolset>gcc:<cxxflags>-Wextra
|
||||
<toolset>gcc:<cxxflags>-pedantic
|
||||
<toolset>gcc:<cxxflags>-Wno-long-long
|
||||
<toolset>gcc:<cxxflags>-Wno-variadic-macros
|
||||
<toolset>darwin:<cxxflags>-Wextra
|
||||
<toolset>darwin:<cxxflags>-pedantic
|
||||
<toolset>darwin:<cxxflags>-Wno-long-long
|
||||
<toolset>darwin:<cxxflags>-Wno-variadic-macros
|
||||
#<toolset>pathscale:<cxxflags>-Wextra
|
||||
<toolset>pathscale:<cxxflags>-Wno-long-long
|
||||
<toolset>pathscale:<cxxflags>-pedantic
|
||||
<toolset>clang:<cxxflags>-Wextra
|
||||
<toolset>clang:<cxxflags>-pedantic
|
||||
<toolset>clang:<cxxflags>-Wno-long-long
|
||||
<toolset>clang:<cxxflags>-Wno-variadic-macros
|
||||
<toolset>gcc-4.5.0,<target-os>windows:<cxxflags>-Wno-missing-field-initializers
|
||||
<toolset>gcc-4.5.0,<target-os>windows:<cxxflags>-fdiagnostics-show-option
|
||||
<toolset>msvc:<cxxflags>/wd4127
|
||||
<toolset>msvc:<cxxflags>/wd4512
|
||||
# Note: Some of the remarks from the Intel compiler are disabled
|
||||
# remark #193: zero used for undefined preprocessing identifier "XXX"
|
||||
# remark #304: access control not specified ("public" by default)
|
||||
# remark #383: value copied to temporary, reference to temporary used
|
||||
# remark #444: destructor for base class "XXX" (declared at line YYY") is not virtual
|
||||
# remark #593: variable "XXX" was set but never used
|
||||
# remark #981: operands are evaluated in unspecified order
|
||||
# remark #1418: external function definition with no prior declaration
|
||||
# remark #2415: variable "XXX" of static storage duration was declared but never referenced
|
||||
|
||||
<toolset>intel:<cxxflags>-wd193,304,383,444
|
||||
<toolset>intel:<cxxflags>-wd593,981
|
||||
<toolset>intel:<cxxflags>-wd1418
|
||||
<toolset>intel:<cxxflags>-wd2415
|
||||
;
|
||||
|
||||
|
||||
|
||||
rule stopwatch-run ( sources + )
|
||||
{
|
||||
return
|
||||
[ run $(sources)
|
||||
: :
|
||||
:
|
||||
<library>/boost/chrono//boost_chrono
|
||||
<library>/boost/system//boost_system
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(sources[1]:B)_d ]
|
||||
[ run $(sources)
|
||||
: :
|
||||
: <define>BOOST_CHRONO_HEADER_ONLY
|
||||
<define>BOOST_ERROR_CODE_HEADER_ONLY
|
||||
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(name)_h ]
|
||||
;
|
||||
}
|
||||
|
||||
rule stopwatch-run2 ( sources + : name )
|
||||
{
|
||||
return
|
||||
[ run $(sources)
|
||||
: :
|
||||
:
|
||||
<library>/boost/chrono//boost_chrono
|
||||
<library>/boost/system//boost_system
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(name)_d ]
|
||||
[ run $(sources)
|
||||
: :
|
||||
: <define>BOOST_CHRONO_HEADER_ONLY
|
||||
<define>BOOST_ERROR_CODE_HEADER_ONLY
|
||||
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(name)_h ]
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
test-suite "stopwatch"
|
||||
:
|
||||
[ stopwatch-run2 stopwatch/simple_stopwatch_pass.cpp : simple_stopwatch_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_pass.cpp : basic_stopwatch_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_last_lap_pass.cpp : basic_stopwatch_last_lap_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_accumulator_set_pass.cpp : basic_stopwatch_laps_accumulator_set_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_container_pass.cpp : basic_stopwatch_laps_container_p ]
|
||||
|
||||
[ stopwatch-run2 stopwatch/suspendable_stopwatch_pass.cpp : suspendable_stopwatch_p ]
|
||||
;
|
||||
|
||||
test-suite "stopwatch_ex"
|
||||
:
|
||||
[ stopwatch-run2 ../example/stopwatch_example.cpp : stopwatch_example ]
|
||||
;
|
||||
|
||||
test-suite "stopclock"
|
||||
:
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_accumulator_set_pass.cpp : basic_stopwatch_reporter_laps_accumulator_set_p ]
|
||||
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_container_pass.cpp : basic_stopwatch_reporter_laps_container_p ]
|
||||
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
|
||||
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_pass.cpp : basic_stopwatch_reporter_p ]
|
||||
[ stopwatch-run2 stopwatch/laps_stopclock_pass.cpp : laps_stopclock_p ]
|
||||
[ stopwatch-run2 stopwatch/laps_stopclock_laps_accumulator_set_pass.cpp : laps_stopclock_laps_accumulator_set_p ]
|
||||
[ stopwatch-run2 stopwatch/simple_stopclock_pass.cpp : simple_stopclock_p ]
|
||||
[ stopwatch-run2 stopwatch/simple_stopwatch_reporter_pass.cpp : simple_stopwatch_reporter_p ]
|
||||
|
||||
;
|
||||
test-suite "stopclock_ex"
|
||||
:
|
||||
[ stopwatch-run2 ../example/stopwatch_reporter_example.cpp : stopwatch_reporter_example ]
|
||||
;
|
||||
|
||||
|
||||
explicit ts_ ;
|
||||
test-suite ts_
|
||||
:
|
||||
;
|
||||
|
82
stopwatches/test/cycle_count.hpp
Normal file
82
stopwatches/test/cycle_count.hpp
Normal file
@ -0,0 +1,82 @@
|
||||
// Copyright 2010 Vicente J. Botet Escriba
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_CHRONO_TEST_CYCLE_COUNT_HPP
|
||||
#define BOOST_CHRONO_TEST_CYCLE_COUNT_HPP
|
||||
|
||||
#include <boost/chrono/ceil.hpp>
|
||||
#include <boost/chrono/duration.hpp>
|
||||
#include <boost/chrono/time_point.hpp>
|
||||
#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp>
|
||||
#include <boost/chrono/stopwatches/formatters/elapsed_formatter.hpp>
|
||||
#include <boost/chrono/stopwatches/strict_stopwatch.hpp>
|
||||
|
||||
namespace ex
|
||||
{
|
||||
template <long long speed>
|
||||
struct cycle_count
|
||||
{
|
||||
typedef typename boost::ratio_multiply<boost::ratio<speed>, boost::mega>::type frequency; // Mhz
|
||||
typedef typename boost::ratio_divide<boost::ratio<1>, frequency>::type period;
|
||||
typedef long long rep;
|
||||
typedef boost::chrono::duration<rep, period> duration;
|
||||
typedef boost::chrono::time_point<cycle_count> time_point;
|
||||
BOOST_STATIC_CONSTEXPR bool is_steady = true;
|
||||
static long long ticks_;
|
||||
|
||||
static time_point now()
|
||||
{
|
||||
// return exact cycle count
|
||||
return time_point(duration(ticks_));
|
||||
}
|
||||
static time_point now(boost::system::error_code & )
|
||||
{
|
||||
// return exact cycle count
|
||||
return time_point(duration(ticks_));
|
||||
}
|
||||
static void advance(std::size_t ticks)
|
||||
{
|
||||
ticks_ += ticks;
|
||||
}
|
||||
template <typename D>
|
||||
static void advance(D const& d)
|
||||
{
|
||||
ticks_ += boost::chrono::ceil<duration>(d).count();
|
||||
}
|
||||
};
|
||||
template <long long speed>
|
||||
long long cycle_count<speed>::ticks_ = 0;
|
||||
|
||||
|
||||
template<class Clock, class Rep, class Period>
|
||||
void sleep_for(const boost::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
Clock::advance(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace chrono
|
||||
{
|
||||
|
||||
template <typename CharT, long long speed>
|
||||
struct basic_stopwatch_reporter_default_formatter<CharT, strict_stopwatch<ex::cycle_count<speed> > >
|
||||
{
|
||||
typedef basic_elapsed_formatter<milli, CharT> type;
|
||||
};
|
||||
|
||||
// template <long long speed>
|
||||
// struct wstopwatch_reporter_default_formatter<strict_stopwatch<ex::cycle_count<speed> > >
|
||||
// {
|
||||
// typedef welapsed_formatter type;
|
||||
// };
|
||||
|
||||
} // namespace chrono
|
||||
} // namespace boost
|
||||
|
||||
|
||||
#endif
|
@ -139,44 +139,6 @@ rule chrono-run2 ( sources : name )
|
||||
;
|
||||
}
|
||||
|
||||
rule stopwatch-run ( sources + )
|
||||
{
|
||||
return
|
||||
[ run $(sources) ../build//boost_chrono
|
||||
: :
|
||||
:
|
||||
<library>/boost/system//boost_system
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(sources[1]:B)_d ]
|
||||
[ run $(sources)
|
||||
: :
|
||||
: <define>BOOST_CHRONO_HEADER_ONLY
|
||||
<define>BOOST_ERROR_CODE_HEADER_ONLY
|
||||
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(name)_h ]
|
||||
;
|
||||
}
|
||||
|
||||
rule stopwatch-run2 ( sources + : name )
|
||||
{
|
||||
return
|
||||
[ run $(sources) ../build//boost_chrono
|
||||
: :
|
||||
:
|
||||
<library>/boost/system//boost_system
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(name)_d ]
|
||||
[ run $(sources)
|
||||
: :
|
||||
: <define>BOOST_CHRONO_HEADER_ONLY
|
||||
<define>BOOST_ERROR_CODE_HEADER_ONLY
|
||||
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
|
||||
<define>BOOST_CHRONO_VERSION=2
|
||||
: $(name)_h ]
|
||||
;
|
||||
}
|
||||
|
||||
rule date-run ( sources + )
|
||||
{
|
||||
return
|
||||
@ -458,40 +420,6 @@ rule chrono-compile2 ( sources : name )
|
||||
[ chrono-run2-mt one_obj.cpp another_obj.cpp : two_obj_p ]
|
||||
;
|
||||
|
||||
test-suite "stopwatch"
|
||||
:
|
||||
[ stopwatch-run2 stopwatch/simple_stopwatch_pass.cpp : simple_stopwatch_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_pass.cpp : basic_stopwatch_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_last_lap_pass.cpp : basic_stopwatch_last_lap_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_accumulator_set_pass.cpp : basic_stopwatch_laps_accumulator_set_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_container_pass.cpp : basic_stopwatch_laps_container_p ]
|
||||
|
||||
[ stopwatch-run2 stopwatch/suspendable_stopwatch_pass.cpp : suspendable_stopwatch_p ]
|
||||
;
|
||||
|
||||
test-suite "stopwatch_ex"
|
||||
:
|
||||
[ stopwatch-run2 ../example/stopwatch_example.cpp : stopwatch_example ]
|
||||
;
|
||||
|
||||
test-suite "stopclock"
|
||||
:
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_accumulator_set_pass.cpp : basic_stopwatch_reporter_laps_accumulator_set_p ]
|
||||
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_container_pass.cpp : basic_stopwatch_reporter_laps_container_p ]
|
||||
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
|
||||
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
|
||||
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_pass.cpp : basic_stopwatch_reporter_p ]
|
||||
[ stopwatch-run2 stopwatch/laps_stopclock_pass.cpp : laps_stopclock_p ]
|
||||
[ stopwatch-run2 stopwatch/laps_stopclock_laps_accumulator_set_pass.cpp : laps_stopclock_laps_accumulator_set_p ]
|
||||
[ stopwatch-run2 stopwatch/simple_stopclock_pass.cpp : simple_stopclock_p ]
|
||||
[ stopwatch-run2 stopwatch/simple_stopwatch_reporter_pass.cpp : simple_stopwatch_reporter_p ]
|
||||
|
||||
;
|
||||
test-suite "stopclock_ex"
|
||||
:
|
||||
[ stopwatch-run2 ../example/stopwatch_reporter_example.cpp : stopwatch_reporter_example ]
|
||||
;
|
||||
|
||||
test-suite "io_ex"
|
||||
:
|
||||
[ chrono-v1-v2-run ../example/io_ex1.cpp ]
|
||||
|
Loading…
x
Reference in New Issue
Block a user