[geometry][index] test: added query iterators, benchmark: removed unneeded tests versions of query iterators.

[SVN r85508]
This commit is contained in:
Adam Wulkiewicz 2013-08-29 00:36:52 +00:00
parent 242ef41cf1
commit 10a847f62f
2 changed files with 20 additions and 120 deletions

View File

@ -8,8 +8,6 @@
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
#define BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
#define BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS_MOVE
#include <iostream>
@ -176,7 +174,7 @@ int main()
std::cout << time << " - query(B) " << queries_count << " found " << temp << '\n';
}
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
@ -211,7 +209,7 @@ int main()
dur_t time = clock_t::now() - start;
std::cout << time << " - qbegin(B) qend() " << queries_count << " found " << temp << '\n';
}
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
@ -236,64 +234,14 @@ int main()
float x = coords[i].first;
float y = coords[i].second;
result.clear();
RT::const_query_iterator_alt first = t.qbegin(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
RT::const_query_iterator_alt last = t.qend(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
RT::const_query_iterator first = t.qbegin(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
RT::const_query_iterator last = t.qend();
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased2 qbegin(B) qend(B) " << queries_count << " found " << temp << '\n';
std::cout << time << " - type-erased qbegin(B) qend() " << queries_count << " found " << temp << '\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();
RT::const_query_iterator_alt first = t.qbegin(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
RT::const_query_iterator_alt last = t.qend();
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased2 qbegin(B) qend() " << queries_count << " found " << temp << '\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();
RT::const_query_iterator_alt2 first = t.qbegin(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
RT::const_query_iterator_alt2 last = t.qend(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased3 qbegin(B) qend(B) " << queries_count << " found " << temp << '\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();
RT::const_query_iterator_alt2 first = t.qbegin(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))));
RT::const_query_iterator_alt2 last = t.qend();
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased3 qbegin(B) qend() " << queries_count << " found " << temp << '\n';
}
#endif
#endif
{
clock_t::time_point start = clock_t::now();
@ -338,7 +286,6 @@ int main()
std::cout << time << " - query(nearest(P, " << neighbours_count << ")) " << nearest_queries_count << " found " << temp << '\n';
}
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
@ -373,7 +320,7 @@ int main()
dur_t time = clock_t::now() - start;
std::cout << time << " - qbegin(nearest(P, " << neighbours_count << ")) qend() " << nearest_queries_count << " found " << temp << '\n';
}
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
@ -398,63 +345,16 @@ int main()
float x = coords[i].first;
float y = coords[i].second;
result.clear();
RT::const_query_iterator_alt first = t.qbegin(bgi::nearest(P(x, y), neighbours_count));
RT::const_query_iterator_alt last = t.qend(bgi::nearest(P(x, y), neighbours_count));
RT::const_query_iterator first = t.qbegin(bgi::nearest(P(x, y), neighbours_count));
RT::const_query_iterator last = t.qend();
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased2 qbegin(nearest(P, " << neighbours_count << ")) qend(n) " << nearest_queries_count << " found " << temp << '\n';
std::cout << time << " - type-erased qbegin(nearest(P, " << neighbours_count << ")) qend() " << nearest_queries_count << " found " << temp << '\n';
}
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
for (size_t i = 0 ; i < nearest_queries_count ; ++i )
{
float x = coords[i].first;
float y = coords[i].second;
result.clear();
RT::const_query_iterator_alt first = t.qbegin(bgi::nearest(P(x, y), neighbours_count));
RT::const_query_iterator_alt last = t.qend();
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased2 qbegin(nearest(P, " << neighbours_count << ")) qend() " << nearest_queries_count << " found " << temp << '\n';
}
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
for (size_t i = 0 ; i < nearest_queries_count ; ++i )
{
float x = coords[i].first;
float y = coords[i].second;
result.clear();
RT::const_query_iterator_alt2 first = t.qbegin(bgi::nearest(P(x, y), neighbours_count));
RT::const_query_iterator_alt2 last = t.qend(bgi::nearest(P(x, y), neighbours_count));
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased3 qbegin(nearest(P, " << neighbours_count << ")) qend(n) " << nearest_queries_count << " found " << temp << '\n';
}
{
clock_t::time_point start = clock_t::now();
size_t temp = 0;
for (size_t i = 0 ; i < nearest_queries_count ; ++i )
{
float x = coords[i].first;
float y = coords[i].second;
result.clear();
RT::const_query_iterator_alt2 first = t.qbegin(bgi::nearest(P(x, y), neighbours_count));
RT::const_query_iterator_alt2 last = t.qend();
std::copy(first, last, std::back_inserter(result));
temp += result.size();
}
dur_t time = clock_t::now() - start;
std::cout << time << " - type-erased3 qbegin(nearest(P, " << neighbours_count << ")) qend() " << nearest_queries_count << " found " << temp << '\n';
}
#endif
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
{
LS ls;

View File

@ -18,7 +18,7 @@
// TEST
//#define BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
//#define BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
#include <boost/geometry/index/rtree.hpp>
#include <boost/geometry/index/detail/rtree/utilities/are_levels_ok.hpp>
@ -668,13 +668,11 @@ void spatial_query(Rtree & rtree, Predicates const& pred, std::vector<Value> con
exactly_the_same_outputs(rtree, output, rtree | bgi::adaptors::queried(pred));
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
std::vector<Value> output3;
std::copy(rtree.qbegin(pred), rtree.qend(pred), std::back_inserter(output3));
compare_outputs(rtree, output3, expected_output);
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
{
typedef typename Rtree::const_query_iterator QI;
QI first = rtree.qbegin(pred);
@ -682,9 +680,11 @@ void spatial_query(Rtree & rtree, Predicates const& pred, std::vector<Value> con
std::vector<Value> output4;
std::copy(first, last, std::back_inserter(output4));
compare_outputs(rtree, output4, expected_output);
QI last2 = rtree.qend();
output4.clear();
std::copy(first, last2, std::back_inserter(output4));
compare_outputs(rtree, output4, expected_output);
}
#endif
#endif
}
// rtree specific queries tests
@ -1039,13 +1039,11 @@ void nearest_query_k(Rtree const& rtree, std::vector<Value> const& input, Point
exactly_the_same_outputs(rtree, output, output2);
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
std::vector<Value> output3;
std::copy(rtree.qbegin(bgi::nearest(pt, k)), rtree.qend(bgi::nearest(pt, k)), std::back_inserter(output3));
compare_nearest_outputs(rtree, output3, expected_output, pt, greatest_distance);
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_ENABLE_TYPE_ERASED_ITERATORS
{
typedef typename Rtree::const_query_iterator QI;
QI first = rtree.qbegin(bgi::nearest(pt, k));
@ -1053,9 +1051,11 @@ void nearest_query_k(Rtree const& rtree, std::vector<Value> const& input, Point
std::vector<Value> output4;
std::copy(first, last, std::back_inserter(output4));
compare_nearest_outputs(rtree, output4, expected_output, pt, greatest_distance);
QI last2 = rtree.qend();
output4.clear();
std::copy(first, last, std::back_inserter(output4));
compare_nearest_outputs(rtree, output4, expected_output, pt, greatest_distance);
}
#endif
#endif
}
// rtree nearest not found