summaryrefslogtreecommitdiff
path: root/libs/timer
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-08-05 19:32:57 +0000
committer <>2014-10-07 10:01:33 +0000
commit1c3648bf5b7d17fcd4fe9bc95802b16fd9eee304 (patch)
tree03de66686a262696ec2ac408e62250dc1f0c01aa /libs/timer
parent8c4528713d907ee2cfd3bfcbbad272c749867f84 (diff)
downloadboost-tarball-1c3648bf5b7d17fcd4fe9bc95802b16fd9eee304.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_56_0.tar.bz2.boost_1_56_0
Diffstat (limited to 'libs/timer')
-rw-r--r--libs/timer/src/cpu_timer.cpp21
-rw-r--r--libs/timer/test/Jamfile.v213
-rw-r--r--libs/timer/test/cpu_timer_test.cpp17
3 files changed, 33 insertions, 18 deletions
diff --git a/libs/timer/src/cpu_timer.cpp b/libs/timer/src/cpu_timer.cpp
index be5842d82..efe4afc15 100644
--- a/libs/timer/src/cpu_timer.cpp
+++ b/libs/timer/src/cpu_timer.cpp
@@ -53,10 +53,10 @@ namespace
os.setf(std::ios_base::fixed, std::ios_base::floatfield);
os.precision(places);
- const long double sec = 1000000000.0L;
+ const double sec = 1000000000.0L;
nanosecond_type total = times.system + times.user;
- long double wall_sec = times.wall / sec;
- long double total_sec = total / sec;
+ double wall_sec = times.wall / sec;
+ double total_sec = total / sec;
for (const char* format = fmt.c_str(); *format; ++format)
{
@@ -69,7 +69,7 @@ namespace
switch (*format)
{
case 'w':
- os << times.wall / sec;
+ os << wall_sec;
break;
case 'u':
os << times.user / sec;
@@ -78,7 +78,7 @@ namespace
os << times.system / sec;
break;
case 't':
- os << total / sec;
+ os << total_sec;
break;
case 'p':
os.precision(1);
@@ -136,7 +136,7 @@ namespace
# else
tms tm;
clock_t c = ::times(&tm);
- if (c == -1) // error
+ if (c == static_cast<clock_t>(-1)) // error
{
current.system = current.user = boost::timer::nanosecond_type(-1);
}
@@ -173,6 +173,7 @@ namespace boost
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();
}
@@ -185,13 +186,13 @@ namespace boost
// cpu_timer ---------------------------------------------------------------------//
- void cpu_timer::start()
+ void cpu_timer::start() BOOST_NOEXCEPT
{
m_is_stopped = false;
get_cpu_times(m_times);
}
- void cpu_timer::stop()
+ void cpu_timer::stop() BOOST_NOEXCEPT
{
if (is_stopped())
return;
@@ -204,7 +205,7 @@ namespace boost
m_times.system = (current.system - m_times.system);
}
- cpu_times cpu_timer::elapsed() const
+ cpu_times cpu_timer::elapsed() const BOOST_NOEXCEPT
{
if (is_stopped())
return m_times;
@@ -216,7 +217,7 @@ namespace boost
return current;
}
- void cpu_timer::resume()
+ void cpu_timer::resume() BOOST_NOEXCEPT
{
if (is_stopped())
{
diff --git a/libs/timer/test/Jamfile.v2 b/libs/timer/test/Jamfile.v2
index 6210c7d4c..bbb3114cb 100644
--- a/libs/timer/test/Jamfile.v2
+++ b/libs/timer/test/Jamfile.v2
@@ -7,6 +7,9 @@
# See library home page at http://www.boost.org/libs/timer
+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
@@ -35,5 +38,13 @@ project
:
: <test-info>always_show_run_output
]
- [ compile original_timer_test.cpp ]
+ [ compile original_timer_test.cpp
+ ]
+ [ run /boost/tools/inspect//inspect/<variant>release
+ : $(parent) -text -brief # command line
+ : # input files
+ : <dependency>/boost/filesystem//boost_filesystem
+ <test-info>always_show_run_output # requirements
+ : inspect # test name
+ ]
;
diff --git a/libs/timer/test/cpu_timer_test.cpp b/libs/timer/test/cpu_timer_test.cpp
index e13a4ba78..bf9784db9 100644
--- a/libs/timer/test/cpu_timer_test.cpp
+++ b/libs/timer/test/cpu_timer_test.cpp
@@ -36,7 +36,9 @@ namespace
// each constructor
auto_cpu_timer t1;
BOOST_TEST(!t1.is_stopped());
- BOOST_TEST(&t1.ostream() == &cout);
+ // 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();
@@ -46,7 +48,7 @@ namespace
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(&t1a.ostream() == &cout);
BOOST_TEST_EQ(t1a.places(), default_places);
BOOST_TEST_EQ(t1a.format_string(), default_format);
@@ -57,25 +59,25 @@ namespace
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(&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(&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(&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(&t4.ostream() == &cout);
BOOST_TEST_EQ(t4.places(), 1);
BOOST_TEST_EQ(t4.format_string(), string("foo"));
@@ -114,11 +116,12 @@ namespace
t7.stop();
t8.stop();
- cout << " unit test complete\n";
+ cout << " unit test complete" << endl;
}
void format_test()
{
+ cout << "format test..." << endl;
cpu_times times;
times.wall = 5123456789LL;