|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74667 - trunk/libs/chrono/perf
From: vicente.botet_at_[hidden]
Date: 2011-10-03 08:30:56
Author: viboes
Date: 2011-10-03 08:30:55 EDT (Mon, 03 Oct 2011)
New Revision: 74667
URL: http://svn.boost.org/trac/boost/changeset/74667
Log:
Chrono: update perf test with clock names
Text files modified:
trunk/libs/chrono/perf/store_now_in_vector.cpp | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
Modified: trunk/libs/chrono/perf/store_now_in_vector.cpp
==============================================================================
--- trunk/libs/chrono/perf/store_now_in_vector.cpp (original)
+++ trunk/libs/chrono/perf/store_now_in_vector.cpp 2011-10-03 08:30:55 EDT (Mon, 03 Oct 2011)
@@ -12,14 +12,14 @@
#include <sys/times.h> //for times
#include <unistd.h>
-static const std::size_t size = 1000000;
+static const std::size_t size = 10000000;
template <typename Clock>
void perf(std::vector<typename Clock::time_point>& vec)
{
typedef boost::chrono::stopwatch_reporter<boost::chrono::simple_stopwatch<boost::chrono::high_resolution_clock> > Reporter;
Reporter rp;
- for (int i=size; i>0; --i)
+ for (int i=size-1; i>=0; --i)
{
vec[i]=Clock::now();
//vec[i]=typename Clock::time_point(typename Clock::time_point::duration(i));
@@ -30,7 +30,7 @@
{
typedef boost::chrono::stopwatch_reporter<boost::chrono::simple_stopwatch<boost::chrono::high_resolution_clock> > Reporter;
Reporter rp;
- for (int i=size; i>0; --i)
+ for (int i=size-1; i>=0; --i)
{
tms tm;
vec[i]=::times(&tm);
@@ -42,7 +42,7 @@
{
typedef boost::chrono::stopwatch_reporter<boost::chrono::simple_stopwatch<boost::chrono::high_resolution_clock> > Reporter;
Reporter rp;
- for (int i=size; i>0; --i)
+ for (int i=size-1; i>=0; --i)
{
vec[i]=::clock();
//vec[i]=typename Clock::time_point(typename Clock::time_point::duration(i));
@@ -56,11 +56,13 @@
std::vector<typename Clock::time_point> vec(size);
perf<Clock>(vec);
std::size_t cnt=0;
- for (int i=size; i>1; --i)
+ for (int i=size-1; i>1; --i)
{
if (vec[i]==vec[i-1]) ++cnt;
}
- std::cout << cnt << std::endl;
+ std::cout <<"Nb of values eq to preceding: "<< cnt << std::endl;
+ std::cout <<"Diff last-first: "<< boost::chrono::duration_cast<boost::chrono::milliseconds>(vec[0]-vec[size-1]) << std::endl;
+
}
void test2()
{
@@ -73,7 +75,8 @@
std::cout << vec[i] << " " ;
}
std::cout<< std::endl;
- std::cout << cnt << std::endl;
+ std::cout <<"Nb of values eq to preceding: "<< cnt << std::endl;
+ std::cout <<"Diff last-first: "<< vec[0]-vec[size-1] << std::endl;
}
void test3()
@@ -87,20 +90,33 @@
std::cout << vec[i] << " " ;
}
std::cout<< std::endl;
- std::cout << cnt << std::endl;
+ std::cout <<"Nb of values eq to preceding: "<< cnt << std::endl;
+ std::cout <<"Diff last-first: "<< vec[0]-vec[size-1] << std::endl;
}
int main() {
+ std::cout << "system_clock ";
test<boost::chrono::system_clock>();
#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
+ std::cout << "steady_clock " ;
test<boost::chrono::steady_clock>();
#endif
+ std::cout << "high_resolution_clock " ;
+ test<boost::chrono::high_resolution_clock>();
+
#if defined(BOOST_CHRONO_HAS_PROCESS_CLOCKS)
+ std::cout << "process_real_cpu_clock ";
test<boost::chrono::process_real_cpu_clock>();
+ std::cout << "process_user_cpu_clock ";
+ test<boost::chrono::process_user_cpu_clock>();
+ std::cout << "process_system_cpu_clock " ;
+ test<boost::chrono::process_system_cpu_clock>();
#endif
- test<boost::chrono::high_resolution_clock>();
+
+ std::cout << "times ";
test2();
+ std::cout << "clock ";
test3();
return 1;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk