Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83045 - sandbox-branches/geometry/index/example
From: adam.wulkiewicz_at_[hidden]
Date: 2013-02-20 08:02:56


Author: awulkiew
Date: 2013-02-20 08:02:55 EST (Wed, 20 Feb 2013)
New Revision: 83045
URL: http://svn.boost.org/trac/boost/changeset/83045

Log:
chrono used instead of timer in rtree benchmark
Text files modified:
   sandbox-branches/geometry/index/example/benchmark.cpp | 36 ++++++++++++++++++------------------
   1 files changed, 18 insertions(+), 18 deletions(-)

Modified: sandbox-branches/geometry/index/example/benchmark.cpp
==============================================================================
--- sandbox-branches/geometry/index/example/benchmark.cpp (original)
+++ sandbox-branches/geometry/index/example/benchmark.cpp 2013-02-20 08:02:55 EST (Wed, 20 Feb 2013)
@@ -11,16 +11,16 @@
 
 #include <boost/geometry/index/rtree.hpp>
 
-#include <boost/timer.hpp>
+#include <boost/chrono.hpp>
 #include <boost/foreach.hpp>
 #include <boost/random.hpp>
 
 int main()
 {
- boost::timer tim;
-
     namespace bg = boost::geometry;
     namespace bgi = bg::index;
+ typedef boost::chrono::thread_clock clock_t;
+ typedef boost::chrono::duration<float> dur_t;
 
     size_t values_count = 1000000;
     size_t queries_count = 100000;
@@ -66,7 +66,7 @@
 
         // inserting test
         {
- tim.restart();
+ clock_t::time_point start = clock_t::now();
             for (size_t i = 0 ; i < values_count ; ++i )
             {
                 float x = coords[i].first;
@@ -75,8 +75,8 @@
 
                 t.insert(b);
             }
- double time = tim.elapsed();
- std::cout << time << "s - insert " << values_count << '\n';
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - insert " << values_count << '\n';
         }
 
         std::vector<B> result;
@@ -84,7 +84,7 @@
         B result_one;
 
         {
- tim.restart();
+ clock_t::time_point start = clock_t::now();
             size_t temp = 0;
             for (size_t i = 0 ; i < queries_count ; ++i )
             {
@@ -94,12 +94,12 @@
                 t.query(B(P(x - 10, y - 10), P(x + 10, y + 10)), std::back_inserter(result));
                 temp += result.size();
             }
- double time = tim.elapsed();
- std::cout << time << "s - query(B) " << queries_count << " found " << temp << '\n';
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - query(B) " << queries_count << " found " << temp << '\n';
         }
 
         {
- tim.restart();
+ clock_t::time_point start = clock_t::now();
             size_t temp = 0;
             for (size_t i = 0 ; i < queries_count / 2 ; ++i )
             {
@@ -121,14 +121,14 @@
                     );
                 temp += result.size();
             }
- double time = tim.elapsed();
- std::cout << time << "s - query(i && !w && !o) " << queries_count << " found " << temp << '\n';
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - query(i && !w && !o) " << queries_count << " found " << temp << '\n';
         }
 
         result.clear();
 
         {
- tim.restart();
+ clock_t::time_point start = clock_t::now();
             size_t temp = 0;
             for (size_t i = 0 ; i < queries_count / 10 ; ++i )
             {
@@ -137,12 +137,12 @@
                 result.clear();
                 temp += t.query(bgi::nearest(P(x, y), 5), std::back_inserter(result));
             }
- double time = tim.elapsed();
- std::cout << time << "s - query(nearest(P, 5)) " << (queries_count / 10) << " found " << temp << '\n';
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - query(nearest(P, 5)) " << (queries_count / 10) << " found " << temp << '\n';
         }
 
         {
- tim.restart();
+ clock_t::time_point start = clock_t::now();
             for (size_t i = 0 ; i < values_count / 10 ; ++i )
             {
                 float x = coords[i].first;
@@ -151,8 +151,8 @@
 
                 t.remove(b);
             }
- double time = tim.elapsed();
- std::cout << time << "s - remove " << values_count / 10 << '\n';
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - remove " << values_count / 10 << '\n';
         }
 
         std::cout << "------------------------------------------------\n";


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