Skip to content

Commit b2b4636

Browse files
committed
Make Stopwatches a sub-module of Chrono.
1 parent f8d4923 commit b2b4636

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+271
-72
lines changed

README.md

+8

meta/libraries.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"key": "chrono",
4+
"name": "Chrono",
5+
"authors": [
6+
"Howard Hinnant",
7+
"Beman Dawes"
8+
"Vicente J. Botet Escriba"
9+
],
10+
"maintainers": [
11+
"Vicente J. Botet Escriba <vicente.botet -at- wanadoo.fr>"
12+
],
13+
"description":
14+
"Useful time utilities. C++11.",
15+
"std": [ "proposal" ],
16+
"category": [
17+
"Domain", "System"
18+
]
19+
},
20+
{
21+
"key": "chrono/stopwatch",
22+
"name": "Chrono.Stopwatch",
23+
"authors": [
24+
"Vicente J. Botet Escriba"
25+
],
26+
"maintainers": [
27+
"Vicente J. Botet Escriba <vicente.botet -at- wanadoo.fr>"
28+
],
29+
"description":
30+
"Useful stopclocks and stopwatches utilities.",
31+
"documentation": "stopwatches/",
32+
"category": [
33+
"Domain"
34+
]
35+
},
36+
]

stopwatches/test/Jamfile.v2

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# Boost Chrono Library test Jamfile
2+
3+
# Copyright Vicente J. Botet Escriba 2014
4+
5+
# Distributed under the Boost Software License, Version 1.0.
6+
# See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt
7+
8+
# See library home page at http://www.boost.org/libs/chrono/stopwatch
9+
10+
import os ;
11+
import feature ;
12+
13+
project
14+
: requirements
15+
<target-os>freebsd:<linkflags>"-lrt"
16+
<target-os>linux:<linkflags>"-lrt -lpthread"
17+
<toolset>clang/<target-os>linux:<linkflags>"-lpthread"
18+
<toolset>pgi:<linkflags>"-lrt"
19+
#<threading>single:<define>BOOST_CHRONO_THREAD_DISABLED
20+
<toolset>msvc:<asynch-exceptions>on
21+
<define>BOOST_CHRONO_USES_MPL_ASSERT
22+
<define>BOOST_SYSTEM_NO_DEPRECATED
23+
#<toolset>sun:<define>BOOST_COMMON_TYPE_DONT_USE_TYPEOF
24+
#<toolset>sun:<define>BOOST_TYPEOF_EMULATION
25+
<toolset>sun:<define>__typeof__=__typeof__
26+
<warnings>all
27+
<toolset>gcc:<cxxflags>-Wextra
28+
<toolset>gcc:<cxxflags>-pedantic
29+
<toolset>gcc:<cxxflags>-Wno-long-long
30+
<toolset>gcc:<cxxflags>-Wno-variadic-macros
31+
<toolset>darwin:<cxxflags>-Wextra
32+
<toolset>darwin:<cxxflags>-pedantic
33+
<toolset>darwin:<cxxflags>-Wno-long-long
34+
<toolset>darwin:<cxxflags>-Wno-variadic-macros
35+
#<toolset>pathscale:<cxxflags>-Wextra
36+
<toolset>pathscale:<cxxflags>-Wno-long-long
37+
<toolset>pathscale:<cxxflags>-pedantic
38+
<toolset>clang:<cxxflags>-Wextra
39+
<toolset>clang:<cxxflags>-pedantic
40+
<toolset>clang:<cxxflags>-Wno-long-long
41+
<toolset>clang:<cxxflags>-Wno-variadic-macros
42+
<toolset>gcc-4.5.0,<target-os>windows:<cxxflags>-Wno-missing-field-initializers
43+
<toolset>gcc-4.5.0,<target-os>windows:<cxxflags>-fdiagnostics-show-option
44+
<toolset>msvc:<cxxflags>/wd4127
45+
<toolset>msvc:<cxxflags>/wd4512
46+
# Note: Some of the remarks from the Intel compiler are disabled
47+
# remark #193: zero used for undefined preprocessing identifier "XXX"
48+
# remark #304: access control not specified ("public" by default)
49+
# remark #383: value copied to temporary, reference to temporary used
50+
# remark #444: destructor for base class "XXX" (declared at line YYY") is not virtual
51+
# remark #593: variable "XXX" was set but never used
52+
# remark #981: operands are evaluated in unspecified order
53+
# remark #1418: external function definition with no prior declaration
54+
# remark #2415: variable "XXX" of static storage duration was declared but never referenced
55+
56+
<toolset>intel:<cxxflags>-wd193,304,383,444
57+
<toolset>intel:<cxxflags>-wd593,981
58+
<toolset>intel:<cxxflags>-wd1418
59+
<toolset>intel:<cxxflags>-wd2415
60+
;
61+
62+
63+
64+
rule stopwatch-run ( sources + )
65+
{
66+
return
67+
[ run $(sources)
68+
: :
69+
:
70+
<library>/boost/chrono//boost_chrono
71+
<library>/boost/system//boost_system
72+
<define>BOOST_CHRONO_VERSION=2
73+
: $(sources[1]:B)_d ]
74+
[ run $(sources)
75+
: :
76+
: <define>BOOST_CHRONO_HEADER_ONLY
77+
<define>BOOST_ERROR_CODE_HEADER_ONLY
78+
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
79+
<define>BOOST_CHRONO_VERSION=2
80+
: $(name)_h ]
81+
;
82+
}
83+
84+
rule stopwatch-run2 ( sources + : name )
85+
{
86+
return
87+
[ run $(sources)
88+
: :
89+
:
90+
<library>/boost/chrono//boost_chrono
91+
<library>/boost/system//boost_system
92+
<define>BOOST_CHRONO_VERSION=2
93+
: $(name)_d ]
94+
[ run $(sources)
95+
: :
96+
: <define>BOOST_CHRONO_HEADER_ONLY
97+
<define>BOOST_ERROR_CODE_HEADER_ONLY
98+
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
99+
<define>BOOST_CHRONO_VERSION=2
100+
: $(name)_h ]
101+
;
102+
}
103+
104+
105+
106+
test-suite "stopwatch"
107+
:
108+
[ stopwatch-run2 stopwatch/simple_stopwatch_pass.cpp : simple_stopwatch_p ]
109+
[ stopwatch-run2 stopwatch/basic_stopwatch_pass.cpp : basic_stopwatch_p ]
110+
[ stopwatch-run2 stopwatch/basic_stopwatch_last_lap_pass.cpp : basic_stopwatch_last_lap_p ]
111+
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_accumulator_set_pass.cpp : basic_stopwatch_laps_accumulator_set_p ]
112+
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_container_pass.cpp : basic_stopwatch_laps_container_p ]
113+
114+
[ stopwatch-run2 stopwatch/suspendable_stopwatch_pass.cpp : suspendable_stopwatch_p ]
115+
;
116+
117+
test-suite "stopwatch_ex"
118+
:
119+
[ stopwatch-run2 ../example/stopwatch_example.cpp : stopwatch_example ]
120+
;
121+
122+
test-suite "stopclock"
123+
:
124+
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_accumulator_set_pass.cpp : basic_stopwatch_reporter_laps_accumulator_set_p ]
125+
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_container_pass.cpp : basic_stopwatch_reporter_laps_container_p ]
126+
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
127+
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
128+
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_pass.cpp : basic_stopwatch_reporter_p ]
129+
[ stopwatch-run2 stopwatch/laps_stopclock_pass.cpp : laps_stopclock_p ]
130+
[ stopwatch-run2 stopwatch/laps_stopclock_laps_accumulator_set_pass.cpp : laps_stopclock_laps_accumulator_set_p ]
131+
[ stopwatch-run2 stopwatch/simple_stopclock_pass.cpp : simple_stopclock_p ]
132+
[ stopwatch-run2 stopwatch/simple_stopwatch_reporter_pass.cpp : simple_stopwatch_reporter_p ]
133+
134+
;
135+
test-suite "stopclock_ex"
136+
:
137+
[ stopwatch-run2 ../example/stopwatch_reporter_example.cpp : stopwatch_reporter_example ]
138+
;
139+
140+
141+
explicit ts_ ;
142+
test-suite ts_
143+
:
144+
;
145+

stopwatches/test/cycle_count.hpp

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright 2010 Vicente J. Botet Escriba
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// See http://www.boost.org/LICENSE_1_0.txt
4+
5+
#ifndef BOOST_CHRONO_TEST_CYCLE_COUNT_HPP
6+
#define BOOST_CHRONO_TEST_CYCLE_COUNT_HPP
7+
8+
#include <boost/chrono/ceil.hpp>
9+
#include <boost/chrono/duration.hpp>
10+
#include <boost/chrono/time_point.hpp>
11+
#include <boost/chrono/stopwatches/reporters/stopwatch_reporter_default_formatter.hpp>
12+
#include <boost/chrono/stopwatches/formatters/elapsed_formatter.hpp>
13+
#include <boost/chrono/stopwatches/strict_stopwatch.hpp>
14+
15+
namespace ex
16+
{
17+
template <long long speed>
18+
struct cycle_count
19+
{
20+
typedef typename boost::ratio_multiply<boost::ratio<speed>, boost::mega>::type frequency; // Mhz
21+
typedef typename boost::ratio_divide<boost::ratio<1>, frequency>::type period;
22+
typedef long long rep;
23+
typedef boost::chrono::duration<rep, period> duration;
24+
typedef boost::chrono::time_point<cycle_count> time_point;
25+
BOOST_STATIC_CONSTEXPR bool is_steady = true;
26+
static long long ticks_;
27+
28+
static time_point now()
29+
{
30+
// return exact cycle count
31+
return time_point(duration(ticks_));
32+
}
33+
static time_point now(boost::system::error_code & )
34+
{
35+
// return exact cycle count
36+
return time_point(duration(ticks_));
37+
}
38+
static void advance(std::size_t ticks)
39+
{
40+
ticks_ += ticks;
41+
}
42+
template <typename D>
43+
static void advance(D const& d)
44+
{
45+
ticks_ += boost::chrono::ceil<duration>(d).count();
46+
}
47+
};
48+
template <long long speed>
49+
long long cycle_count<speed>::ticks_ = 0;
50+
51+
52+
template<class Clock, class Rep, class Period>
53+
void sleep_for(const boost::chrono::duration<Rep, Period>& d)
54+
{
55+
Clock::advance(d);
56+
}
57+
58+
}
59+
60+
61+
namespace boost
62+
{
63+
namespace chrono
64+
{
65+
66+
template <typename CharT, long long speed>
67+
struct basic_stopwatch_reporter_default_formatter<CharT, strict_stopwatch<ex::cycle_count<speed> > >
68+
{
69+
typedef basic_elapsed_formatter<milli, CharT> type;
70+
};
71+
72+
// template <long long speed>
73+
// struct wstopwatch_reporter_default_formatter<strict_stopwatch<ex::cycle_count<speed> > >
74+
// {
75+
// typedef welapsed_formatter type;
76+
// };
77+
78+
} // namespace chrono
79+
} // namespace boost
80+
81+
82+
#endif

sublibs

Whitespace-only changes.

test/Jamfile.v2

-72
Original file line numberDiff line numberDiff line change
@@ -139,44 +139,6 @@ rule chrono-run2 ( sources : name )
139139
;
140140
}
141141

142-
rule stopwatch-run ( sources + )
143-
{
144-
return
145-
[ run $(sources) ../build//boost_chrono
146-
: :
147-
:
148-
<library>/boost/system//boost_system
149-
<define>BOOST_CHRONO_VERSION=2
150-
: $(sources[1]:B)_d ]
151-
[ run $(sources)
152-
: :
153-
: <define>BOOST_CHRONO_HEADER_ONLY
154-
<define>BOOST_ERROR_CODE_HEADER_ONLY
155-
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
156-
<define>BOOST_CHRONO_VERSION=2
157-
: $(name)_h ]
158-
;
159-
}
160-
161-
rule stopwatch-run2 ( sources + : name )
162-
{
163-
return
164-
[ run $(sources) ../build//boost_chrono
165-
: :
166-
:
167-
<library>/boost/system//boost_system
168-
<define>BOOST_CHRONO_VERSION=2
169-
: $(name)_d ]
170-
[ run $(sources)
171-
: :
172-
: <define>BOOST_CHRONO_HEADER_ONLY
173-
<define>BOOST_ERROR_CODE_HEADER_ONLY
174-
#<define>BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
175-
<define>BOOST_CHRONO_VERSION=2
176-
: $(name)_h ]
177-
;
178-
}
179-
180142
rule date-run ( sources + )
181143
{
182144
return
@@ -458,40 +420,6 @@ rule chrono-compile2 ( sources : name )
458420
[ chrono-run2-mt one_obj.cpp another_obj.cpp : two_obj_p ]
459421
;
460422

461-
test-suite "stopwatch"
462-
:
463-
[ stopwatch-run2 stopwatch/simple_stopwatch_pass.cpp : simple_stopwatch_p ]
464-
[ stopwatch-run2 stopwatch/basic_stopwatch_pass.cpp : basic_stopwatch_p ]
465-
[ stopwatch-run2 stopwatch/basic_stopwatch_last_lap_pass.cpp : basic_stopwatch_last_lap_p ]
466-
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_accumulator_set_pass.cpp : basic_stopwatch_laps_accumulator_set_p ]
467-
[ stopwatch-run2 stopwatch/basic_stopwatch_laps_container_pass.cpp : basic_stopwatch_laps_container_p ]
468-
469-
[ stopwatch-run2 stopwatch/suspendable_stopwatch_pass.cpp : suspendable_stopwatch_p ]
470-
;
471-
472-
test-suite "stopwatch_ex"
473-
:
474-
[ stopwatch-run2 ../example/stopwatch_example.cpp : stopwatch_example ]
475-
;
476-
477-
test-suite "stopclock"
478-
:
479-
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_accumulator_set_pass.cpp : basic_stopwatch_reporter_laps_accumulator_set_p ]
480-
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_laps_container_pass.cpp : basic_stopwatch_reporter_laps_container_p ]
481-
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
482-
#[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_last_lap_pass.cpp : basic_stopwatch_reporter_last_lap_p ]
483-
[ stopwatch-run2 stopwatch/basic_stopwatch_reporter_pass.cpp : basic_stopwatch_reporter_p ]
484-
[ stopwatch-run2 stopwatch/laps_stopclock_pass.cpp : laps_stopclock_p ]
485-
[ stopwatch-run2 stopwatch/laps_stopclock_laps_accumulator_set_pass.cpp : laps_stopclock_laps_accumulator_set_p ]
486-
[ stopwatch-run2 stopwatch/simple_stopclock_pass.cpp : simple_stopclock_p ]
487-
[ stopwatch-run2 stopwatch/simple_stopwatch_reporter_pass.cpp : simple_stopwatch_reporter_p ]
488-
489-
;
490-
test-suite "stopclock_ex"
491-
:
492-
[ stopwatch-run2 ../example/stopwatch_reporter_example.cpp : stopwatch_reporter_example ]
493-
;
494-
495423
test-suite "io_ex"
496424
:
497425
[ chrono-v1-v2-run ../example/io_ex1.cpp ]

0 commit comments

Comments
 (0)