Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83330 - sandbox-branches/geometry/index/example
From: adam.wulkiewicz_at_[hidden]
Date: 2013-03-06 09:15:22


Author: awulkiew
Date: 2013-03-06 09:15:22 EST (Wed, 06 Mar 2013)
New Revision: 83330
URL: http://svn.boost.org/trac/boost/changeset/83330

Log:
benchmark2 modified
Text files modified:
   sandbox-branches/geometry/index/example/benchmark2.cpp | 74 +++++++++++++++++----------------------
   1 files changed, 33 insertions(+), 41 deletions(-)

Modified: sandbox-branches/geometry/index/example/benchmark2.cpp
==============================================================================
--- sandbox-branches/geometry/index/example/benchmark2.cpp (original)
+++ sandbox-branches/geometry/index/example/benchmark2.cpp 2013-03-06 09:15:22 EST (Wed, 06 Mar 2013)
@@ -14,6 +14,7 @@
 #include <boost/chrono.hpp>
 #include <boost/foreach.hpp>
 #include <boost/random.hpp>
+#include <set>
 
 int main()
 {
@@ -22,77 +23,68 @@
     typedef boost::chrono::thread_clock clock_t;
     typedef boost::chrono::duration<float> dur_t;
 
- size_t values_count = 30000001;
- size_t count_start = 500000;
- size_t count_stop = 30000000;
- size_t count_step = 500000;
- size_t insrem_count = 10000;
+ size_t values_count = 501;
+ size_t count_start = 10;
+ size_t count_stop = 500;
+ size_t count_step = 10;
+ size_t insrem_count = 3000000;
 
     std::vector< std::pair<float, float> > coords;
 
- //randomize values
- {
- boost::mt19937 rng;
- //rng.seed(static_cast<unsigned int>(std::time(0)));
- float max_val = static_cast<float>(values_count / 2);
- boost::uniform_real<float> range(-max_val, max_val);
- boost::variate_generator<boost::mt19937&, boost::uniform_real<float> > rnd(rng, range);
-
- coords.reserve(values_count);
-
- std::cout << "randomizing data\n";
- for ( size_t i = 0 ; i < values_count ; ++i )
- {
- coords.push_back(std::make_pair(rnd(), rnd()));
- }
- std::cout << "randomized\n";
- }
-
     //typedef bg::model::d2::point_xy<double> P;
- typedef bg::model::point<double, 2, bg::cs::cartesian> P;
- typedef bgi::rtree<P, bgi::linear<16, 4> > RT;
+ typedef bg::model::point<double, 1, bg::cs::cartesian> P;
+ typedef bgi::rtree<P, bgi::linear<8, 3> > RT;
     //typedef bgi::rtree<P, bgi::runtime::linear > RT;
     //typedef bgi::rtree<P, bgi::quadratic<32, 8> > RT;
     //typedef bgi::rtree<P, bgi::runtime::quadratic > RT;
     //typedef bgi::rtree<P, bgi::rstar<32, 8> > RT;
     //typedef bgi::rtree<P, bgi::runtime::rstar > RT;
 
- std::cout << "sizeof rtree: " << sizeof(RT) << std::endl;
-
+ RT t;
+ std::set<float> s;
+ size_t val_i = 0;
     for ( size_t curr_count = count_start ; curr_count < count_stop ; curr_count += count_step )
     {
- RT t;
         //RT t(bgi::runtime::linear(32, 8));
         //RT t(bgi::runtime::quadratic(32, 8));
         //RT t(bgi::runtime::rstar(32, 8));
 
- std::cout << curr_count << ' ';
-
         // inserting test
         {
- for (size_t i = 0 ; i < curr_count ; ++i )
+ for (; val_i < curr_count ; ++val_i )
             {
- float x = coords[i].first;
- float y = coords[i].second;
- P p(x, y);
-
+ float v = val_i / 100.0f;
+ P p(v);
                 t.insert(p);
+ s.insert(v);
             }
 
+ float v = (val_i+1) / 100.0f;
+ P test_p(v);
+
+ std::cout << t.size() << ' ';
+
             clock_t::time_point start = clock_t::now();
 
             for (size_t i = 0 ; i < insrem_count ; ++i )
             {
- float x = coords.back().first;
- float y = coords.back().second;
- P p(x, y);
-
- t.insert(p);
- t.remove(p);
+ t.insert(test_p);
+ t.remove(test_p);
             }
 
             dur_t time = clock_t::now() - start;
             std::cout << time.count() << ' ';
+
+ start = clock_t::now();
+
+ for (size_t i = 0 ; i < insrem_count ; ++i )
+ {
+ s.insert(v);
+ s.erase(v);
+ }
+
+ time = clock_t::now() - start;
+ std::cout << time.count() << ' ';
         }
 
         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