|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84721 - in trunk/libs/geometry/index: example test
From: adam.wulkiewicz_at_[hidden]
Date: 2013-06-09 23:45:43
Author: awulkiew
Date: 2013-06-09 23:45:43 EDT (Sun, 09 Jun 2013)
New Revision: 84721
URL: http://svn.boost.org/trac/boost/changeset/84721
Log:
geometry.index: test - fixed varray warnings, example - code using packing added to glut_vis and benchmark_experimental.
Text files modified:
trunk/libs/geometry/index/example/benchmark_experimental.cpp | 64 +++++++++++++++++++++++++++++++--------
trunk/libs/geometry/index/example/glut_vis.cpp | 30 ++++++++++++++++++
trunk/libs/geometry/index/test/movable.hpp | 28 ++++++++--------
trunk/libs/geometry/index/test/varray.cpp | 30 +++++++++---------
trunk/libs/geometry/index/test/varray_test.hpp | 22 ++++++------
5 files changed, 120 insertions(+), 54 deletions(-)
Modified: trunk/libs/geometry/index/example/benchmark_experimental.cpp
==============================================================================
--- trunk/libs/geometry/index/example/benchmark_experimental.cpp Sun Jun 9 23:43:10 2013 (r84720)
+++ trunk/libs/geometry/index/example/benchmark_experimental.cpp 2013-06-09 23:45:43 EDT (Sun, 09 Jun 2013) (r84721)
@@ -35,11 +35,14 @@
*o = *first;
}
+//#define BOOST_GEOMETRY_INDEX_BENCHMARK_DEBUG
+
int main()
{
typedef boost::chrono::thread_clock clock_t;
typedef boost::chrono::duration<float> dur_t;
+#ifndef BOOST_GEOMETRY_INDEX_BENCHMARK_DEBUG
size_t values_count = 1000000;
size_t queries_count = 100000;
size_t nearest_queries_count = 10000;
@@ -47,9 +50,19 @@
size_t path_queries_count = 2000;
size_t path_queries_count2 = 10000;
unsigned path_values_count = 10;
+#else
+ size_t values_count = 1000;
+ size_t queries_count = 1;
+ size_t nearest_queries_count = 1;
+ unsigned neighbours_count = 10;
+ size_t path_queries_count = 1;
+ size_t path_queries_count2 = 1;
+ unsigned path_values_count = 10;
+#endif
float max_val = static_cast<float>(values_count / 2);
std::vector< std::pair<float, float> > coords;
+ std::vector<B> values;
//randomize values
{
@@ -63,39 +76,62 @@
std::cout << "randomizing data\n";
for ( size_t i = 0 ; i < values_count ; ++i )
{
- coords.push_back(std::make_pair(rnd(), rnd()));
+ float x = rnd();
+ float y = rnd();
+ coords.push_back(std::make_pair(x, y));
+ values.push_back(B(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)));
}
std::cout << "randomized\n";
}
- typedef bgi::rtree<B, bgi::linear<16, 4> > RT;
+ //typedef bgi::rtree<B, bgi::linear<100, 50> > RT;
//typedef bgi::rtree<B, bgi::quadratic<8, 3> > RT;
- //typedef bgi::rtree<B, bgi::rstar<8, 3> > RT;
+ typedef bgi::rtree<B, bgi::rstar<8, 3> > RT;
std::cout << "sizeof rtree: " << sizeof(RT) << std::endl;
for (;;)
{
- RT t;
+ std::vector<B> result;
+ result.reserve(100);
+ B result_one;
- // inserting test
+ // packing test
{
clock_t::time_point start = clock_t::now();
- for (size_t i = 0 ; i < values_count ; ++i )
- {
- float x = coords[i].first;
- float y = coords[i].second;
- B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f));
- t.insert(b);
+ RT t(values.begin(), values.end());
+
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - pack " << values_count << '\n';
+
+ {
+ clock_t::time_point start = clock_t::now();
+ size_t temp = 0;
+ for (size_t i = 0 ; i < queries_count ; ++i )
+ {
+ float x = coords[i].first;
+ float y = coords[i].second;
+ result.clear();
+ t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result));
+ temp += result.size();
+ }
+ dur_t time = clock_t::now() - start;
+ std::cout << time << " - query(B) " << queries_count << " found " << temp << '\n';
}
+ }
+
+ RT t;
+
+ // inserting test
+ {
+ clock_t::time_point start = clock_t::now();
+ t.insert(values);
dur_t time = clock_t::now() - start;
std::cout << time << " - insert " << values_count << '\n';
}
- std::vector<B> result;
- result.reserve(100);
- B result_one;
+
{
clock_t::time_point start = clock_t::now();
Modified: trunk/libs/geometry/index/example/glut_vis.cpp
==============================================================================
--- trunk/libs/geometry/index/example/glut_vis.cpp Sun Jun 9 23:43:10 2013 (r84720)
+++ trunk/libs/geometry/index/example/glut_vis.cpp 2013-06-09 23:45:43 EDT (Sun, 09 Jun 2013) (r84721)
@@ -622,6 +622,36 @@
glutPostRedisplay();
}
+ else if ( current_line == "bulk" )
+ {
+ vect.clear();
+
+ for ( size_t i = 0 ; i < 35 ; ++i )
+ {
+ float x = ( rand() % 100 );
+ float y = ( rand() % 100 );
+ float w = ( rand() % 2 ) + 1;
+ float h = ( rand() % 2 ) + 1;
+
+ B b(P(x - w, y - h),P(x + w, y + h));
+ vect.push_back(b);
+
+ std::cout << "inserted: ";
+ bgi::detail::utilities::print_indexable(std::cout, b);
+ std::cout << '\n';
+ }
+
+ RTree t2(vect);
+ t = boost::move(t2);
+
+ std::cout << ( bgi::detail::rtree::utilities::are_boxes_ok(t) ? "boxes OK\n" : "WRONG BOXES!\n" );
+ std::cout << ( bgi::detail::rtree::utilities::are_levels_ok(t) ? "levels OK\n" : "WRONG LEVELS!\n" );
+ std::cout << "\n";
+
+ search_valid = false;
+
+ glutPostRedisplay();
+ }
else
{
if ( current_line == "knn" )
Modified: trunk/libs/geometry/index/test/movable.hpp
==============================================================================
--- trunk/libs/geometry/index/test/movable.hpp Sun Jun 9 23:43:10 2013 (r84720)
+++ trunk/libs/geometry/index/test/movable.hpp 2013-06-09 23:45:43 EDT (Sun, 09 Jun 2013) (r84721)
@@ -1,15 +1,15 @@
-//////////////////////////////////////////////////////////////////////////////
-//
-// (C) Copyright Ion Gaztanaga 2009.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
+// Boost.Geometry.Index varray
+// Unit Test
+
+// Copyright (c) 2009 Ion Gaztanaga
+// Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-//
-// See http://www.boost.org/libs/move for documentation.
-//
-//////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_MOVE_TEST_MOVABLE_HPP
-#define BOOST_MOVE_TEST_MOVABLE_HPP
+
+#ifndef BOOST_GEOMETRY_INDEX_TEST_MOVABLE_HPP
+#define BOOST_GEOMETRY_INDEX_TEST_MOVABLE_HPP
//[movable_definition
//header file "movable.hpp"
@@ -39,10 +39,10 @@
class copy_movable
{
BOOST_COPYABLE_AND_MOVABLE(copy_movable)
- int value_;
+ size_t value_;
public:
- copy_movable(int value = 1) : value_(value){}
+ copy_movable(size_t value = 1) : value_(value){}
//Move constructor and assignment
copy_movable(BOOST_RV_REF(copy_movable) m)
@@ -89,4 +89,4 @@
} //namespace boost{
//]
-#endif //BOOST_MOVE_TEST_MOVABLE_HPP
+#endif //BOOST_GEOMETRY_INDEX_TEST_MOVABLE_HPP
Modified: trunk/libs/geometry/index/test/varray.cpp
==============================================================================
--- trunk/libs/geometry/index/test/varray.cpp Sun Jun 9 23:43:10 2013 (r84720)
+++ trunk/libs/geometry/index/test/varray.cpp 2013-06-09 23:45:43 EDT (Sun, 09 Jun 2013) (r84721)
@@ -659,98 +659,98 @@
{
BOOST_CHECK(counting_value::count() == 0);
- test_ctor_ndc<int, 10>();
+ test_ctor_ndc<size_t, 10>();
test_ctor_ndc<value_ndc, 10>();
test_ctor_ndc<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
test_ctor_ndc<shptr_value, 10>();
test_ctor_ndc<copy_movable, 10>();
- test_ctor_nc<int, 10>(5);
+ test_ctor_nc<size_t, 10>(5);
test_ctor_nc<value_nc, 10>(5);
test_ctor_nc<counting_value, 10>(5);
BOOST_CHECK(counting_value::count() == 0);
test_ctor_nc<shptr_value, 10>(5);
test_ctor_nc<copy_movable, 10>(5);
- test_ctor_nd<int, 10>(5, 1);
+ test_ctor_nd<size_t, 10>(5, 1);
test_ctor_nd<value_nd, 10>(5, value_nd(1));
test_ctor_nd<counting_value, 10>(5, counting_value(1));
BOOST_CHECK(counting_value::count() == 0);
test_ctor_nd<shptr_value, 10>(5, shptr_value(1));
test_ctor_nd<copy_movable, 10>(5, produce());
- test_resize_nc<int, 10>(5);
+ test_resize_nc<size_t, 10>(5);
test_resize_nc<value_nc, 10>(5);
test_resize_nc<counting_value, 10>(5);
BOOST_CHECK(counting_value::count() == 0);
test_resize_nc<shptr_value, 10>(5);
test_resize_nc<copy_movable, 10>(5);
- test_resize_nd<int, 10>(5, 1);
+ test_resize_nd<size_t, 10>(5, 1);
test_resize_nd<value_nd, 10>(5, value_nd(1));
test_resize_nd<counting_value, 10>(5, counting_value(1));
BOOST_CHECK(counting_value::count() == 0);
test_resize_nd<shptr_value, 10>(5, shptr_value(1));
test_resize_nd<copy_movable, 10>(5, produce());
- test_push_back_nd<int, 10>();
+ test_push_back_nd<size_t, 10>();
test_push_back_nd<value_nd, 10>();
test_push_back_nd<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
test_push_back_nd<shptr_value, 10>();
test_push_back_nd<copy_movable, 10>();
- test_pop_back_nd<int, 10>();
+ test_pop_back_nd<size_t, 10>();
test_pop_back_nd<value_nd, 10>();
test_pop_back_nd<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
test_pop_back_nd<shptr_value, 10>();
test_pop_back_nd<copy_movable, 10>();
- test_copy_and_assign_nd<int, 10>(1);
+ test_copy_and_assign_nd<size_t, 10>(1);
test_copy_and_assign_nd<value_nd, 10>(value_nd(1));
test_copy_and_assign_nd<counting_value, 10>(counting_value(1));
BOOST_CHECK(counting_value::count() == 0);
test_copy_and_assign_nd<shptr_value, 10>(shptr_value(1));
test_copy_and_assign_nd<copy_movable, 10>(produce());
- test_iterators_nd<int, 10>();
+ test_iterators_nd<size_t, 10>();
test_iterators_nd<value_nd, 10>();
test_iterators_nd<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
test_iterators_nd<shptr_value, 10>();
test_iterators_nd<copy_movable, 10>();
- test_erase_nd<int, 10>();
+ test_erase_nd<size_t, 10>();
test_erase_nd<value_nd, 10>();
test_erase_nd<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
test_erase_nd<shptr_value, 10>();
test_erase_nd<copy_movable, 10>();
- test_insert_nd<int, 10>(50);
+ test_insert_nd<size_t, 10>(50);
test_insert_nd<value_nd, 10>(value_nd(50));
test_insert_nd<counting_value, 10>(counting_value(50));
BOOST_CHECK(counting_value::count() == 0);
test_insert_nd<shptr_value, 10>(shptr_value(50));
test_insert_nd<copy_movable, 10>(produce());
- test_capacity_0_nd<int>();
+ test_capacity_0_nd<size_t>();
test_capacity_0_nd<value_nd>();
test_capacity_0_nd<counting_value>();
BOOST_CHECK(counting_value::count() == 0);
test_capacity_0_nd<shptr_value>();
test_capacity_0_nd<copy_movable>();
- test_exceptions_nd<int, 10>();
+ test_exceptions_nd<size_t, 10>();
test_exceptions_nd<value_nd, 10>();
test_exceptions_nd<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
test_exceptions_nd<shptr_value, 10>();
test_exceptions_nd<copy_movable, 10>();
- test_swap_and_move_nd<int, 10>();
+ test_swap_and_move_nd<size_t, 10>();
test_swap_and_move_nd<value_nd, 10>();
test_swap_and_move_nd<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
@@ -763,7 +763,7 @@
test_emplace_2p<counting_value, 10>();
BOOST_CHECK(counting_value::count() == 0);
- test_sv_elem<int, 10>(50);
+ test_sv_elem<size_t, 10>(50);
test_sv_elem<value_nd, 10>(value_nd(50));
test_sv_elem<counting_value, 10>(counting_value(50));
BOOST_CHECK(counting_value::count() == 0);
Modified: trunk/libs/geometry/index/test/varray_test.hpp
==============================================================================
--- trunk/libs/geometry/index/test/varray_test.hpp Sun Jun 9 23:43:10 2013 (r84720)
+++ trunk/libs/geometry/index/test/varray_test.hpp 2013-06-09 23:45:43 EDT (Sun, 09 Jun 2013) (r84721)
@@ -19,38 +19,38 @@
class value_ndc
{
public:
- explicit value_ndc(int a) : aa(a) {}
+ explicit value_ndc(size_t a) : aa(a) {}
~value_ndc() {}
bool operator==(value_ndc const& v) const { return aa == v.aa; }
bool operator<(value_ndc const& v) const { return aa < v.aa; }
private:
value_ndc(value_ndc const&) {}
value_ndc & operator=(value_ndc const&) { return *this; }
- int aa;
+ size_t aa;
};
class value_nd
{
public:
- explicit value_nd(int a) : aa(a) {}
+ explicit value_nd(size_t a) : aa(a) {}
~value_nd() {}
bool operator==(value_nd const& v) const { return aa == v.aa; }
bool operator<(value_nd const& v) const { return aa < v.aa; }
private:
- int aa;
+ size_t aa;
};
class value_nc
{
public:
- explicit value_nc(int a = 0) : aa(a) {}
+ explicit value_nc(size_t a = 0) : aa(a) {}
~value_nc() {}
bool operator==(value_nc const& v) const { return aa == v.aa; }
bool operator<(value_nc const& v) const { return aa < v.aa; }
private:
value_nc(value_nc const&) {}
value_nc & operator=(value_ndc const&) { return *this; }
- int aa;
+ size_t aa;
};
class counting_value
@@ -58,7 +58,7 @@
BOOST_COPYABLE_AND_MOVABLE(counting_value)
public:
- explicit counting_value(int a = 0, int b = 0) : aa(a), bb(b) { ++c(); }
+ explicit counting_value(size_t a = 0, size_t b = 0) : aa(a), bb(b) { ++c(); }
counting_value(counting_value const& v) : aa(v.aa), bb(v.bb) { ++c(); }
counting_value(BOOST_RV_REF(counting_value) p) : aa(p.aa), bb(p.bb) { p.aa = 0; p.bb = 0; ++c(); } // Move constructor
counting_value& operator=(BOOST_RV_REF(counting_value) p) { aa = p.aa; p.aa = 0; bb = p.bb; p.bb = 0; return *this; } // Move assignment
@@ -70,7 +70,7 @@
private:
static size_t & c() { static size_t co = 0; return co; }
- int aa, bb;
+ size_t aa, bb;
};
namespace boost {
@@ -85,13 +85,13 @@
class shptr_value
{
- typedef boost::shared_ptr<int> Ptr;
+ typedef boost::shared_ptr<size_t> Ptr;
public:
- explicit shptr_value(int a = 0) : m_ptr(new int(a)) {}
+ explicit shptr_value(size_t a = 0) : m_ptr(new size_t(a)) {}
bool operator==(shptr_value const& v) const { return *m_ptr == *(v.m_ptr); }
bool operator<(shptr_value const& v) const { return *m_ptr < *(v.m_ptr); }
private:
- boost::shared_ptr<int> m_ptr;
+ boost::shared_ptr<size_t> m_ptr;
};
#endif // BOOST_GEOMETRY_INDEX_TEST_VARRAY_TEST_HPP
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