mirror of https://github.com/CGAL/cgal
aabb tree demo:
- shorter code for benchmarking - benchmarking duration made as an option
This commit is contained in:
parent
514f1e8973
commit
dffabd3115
|
|
@ -202,15 +202,29 @@ void MainWindow::on_actionEdge_points_triggered()
|
|||
|
||||
void MainWindow::on_actionBench_distances_triggered()
|
||||
{
|
||||
bool ok;
|
||||
const int duration = QInputDialog::getInteger(NULL, "Duration",
|
||||
"Duration (ms):",1000,1,1000000,8,&ok);
|
||||
if(!ok)
|
||||
return;
|
||||
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_pScene->benchmark_distances();
|
||||
std::cout << std::endl << "Benchmark distances" << std::endl;
|
||||
m_pScene->benchmark_distances(duration);
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionBench_intersections_triggered()
|
||||
{
|
||||
bool ok;
|
||||
const int duration = QInputDialog::getInteger(NULL, "Duration",
|
||||
"Duration (ms):",1000,1,1000000,8,&ok);
|
||||
if(!ok)
|
||||
return;
|
||||
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
m_pScene->benchmark_intersections();
|
||||
std::cout << std::endl << "Benchmark intersections" << std::endl;
|
||||
m_pScene->benchmark_intersections(duration);
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,10 +61,6 @@ public:
|
|||
void clear_segments() { m_segments.clear(); }
|
||||
void clear_distance_function() { m_max_distance_function = 0.0; }
|
||||
|
||||
// benchmarks
|
||||
void benchmark_distances();
|
||||
void benchmark_intersections();
|
||||
|
||||
// algorithms
|
||||
void generate_edge_points(const unsigned int nb_points);
|
||||
void generate_inside_points(const unsigned int nb_trials);
|
||||
|
|
@ -94,15 +90,34 @@ public:
|
|||
typedef Facet_tree::Object_and_primitive_id Object_and_primitive_id;
|
||||
typedef Facet_tree::Primitive_id Primitive_id;
|
||||
|
||||
// benchmarks
|
||||
void bench_do_intersect(Facet_tree& tree);
|
||||
void bench_closest_point(Facet_tree& tree);
|
||||
void bench_squared_distance(Facet_tree& tree);
|
||||
void bench_nb_intersections(Facet_tree& tree);
|
||||
void bench_any_intersection(Facet_tree& tree);
|
||||
void bench_all_intersections(Facet_tree& tree);
|
||||
void bench_closest_point_and_primitive(Facet_tree& tree);
|
||||
void bench_all_intersected_primitives(Facet_tree& tree);
|
||||
// benchmarks
|
||||
enum {DO_INTERSECT,
|
||||
ANY_INTERSECTION,
|
||||
NB_INTERSECTIONS,
|
||||
ALL_INTERSECTIONS,
|
||||
ALL_INTERSECTED_PRIMITIVES};
|
||||
void benchmark_intersections(const int duration);
|
||||
void bench_intersection_rays(Facet_tree& tree,const int function,const int duration);
|
||||
void bench_intersection_lines(Facet_tree& tree,const int function,const int duration);
|
||||
void bench_intersection_planes(Facet_tree& tree,const int function,const int duration);
|
||||
void bench_intersection_segments(Facet_tree& tree,const int function,const int duration);
|
||||
|
||||
// distance benchmarks
|
||||
enum {SQ_DISTANCE,
|
||||
CLOSEST_POINT,
|
||||
CLOSEST_POINT_AND_PRIMITIVE_ID};
|
||||
void benchmark_distances(const int duration);
|
||||
void bench_closest_point(Facet_tree& tree,const int duration);
|
||||
void bench_squared_distance(Facet_tree& tree,const int duration);
|
||||
void bench_closest_point_and_primitive(Facet_tree& tree,const int duration);
|
||||
void bench_distance(Facet_tree& tree,const int function,const int duration);
|
||||
|
||||
// intersection benchmarks
|
||||
void bench_do_intersect(Facet_tree& tree,const int duration);
|
||||
void bench_nb_intersections(Facet_tree& tree,const int duration);
|
||||
void bench_any_intersection(Facet_tree& tree,const int duration);
|
||||
void bench_all_intersections(Facet_tree& tree,const int duration);
|
||||
void bench_all_intersected_primitives(Facet_tree& tree,const int duration);
|
||||
|
||||
// drawing
|
||||
void draw_points();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "Scene.h"
|
||||
#include <QInputDialog>
|
||||
|
||||
void Scene::benchmark_intersections()
|
||||
void Scene::benchmark_intersections(const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
|
|
@ -9,18 +9,18 @@ void Scene::benchmark_intersections()
|
|||
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
|
||||
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
||||
|
||||
bench_do_intersect(tree);
|
||||
bench_nb_intersections(tree);
|
||||
bench_any_intersection(tree);
|
||||
bench_all_intersections(tree);
|
||||
bench_all_intersected_primitives(tree);
|
||||
bench_do_intersect(tree,duration);
|
||||
bench_nb_intersections(tree,duration);
|
||||
bench_any_intersection(tree,duration);
|
||||
bench_all_intersections(tree,duration);
|
||||
bench_all_intersected_primitives(tree,duration);
|
||||
}
|
||||
|
||||
void Scene::benchmark_distances()
|
||||
void Scene::benchmark_distances(const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Construct AABB tree...";
|
||||
std::cout << "Construct AABB tree and internal KD tree...";
|
||||
Facet_tree tree(m_pPolyhedron->facets_begin(),m_pPolyhedron->facets_end());
|
||||
tree.accelerate_distance_queries();
|
||||
std::cout << "done (" << time.elapsed() << " ms)" << std::endl;
|
||||
|
|
@ -30,348 +30,257 @@ void Scene::benchmark_distances()
|
|||
tree.closest_point(CGAL::ORIGIN);
|
||||
|
||||
// benchmark
|
||||
bench_closest_point(tree);
|
||||
bench_squared_distance(tree);
|
||||
bench_closest_point_and_primitive(tree);
|
||||
bench_closest_point(tree,duration);
|
||||
bench_squared_distance(tree,duration);
|
||||
bench_closest_point_and_primitive(tree,duration);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BENCH INTERSECTIONS
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
void Scene::bench_all_intersected_primitives(Facet_tree& tree)
|
||||
void Scene::bench_intersection_rays(Facet_tree& tree,
|
||||
const int function,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
unsigned int nb = 0;
|
||||
std::list<Primitive_id> primitive_ids;
|
||||
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark all_intersected_primitives" << std::endl;
|
||||
|
||||
// with ray
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Ray ray = random_ray();
|
||||
tree.all_intersected_primitives(ray,std::back_inserter(primitive_ids));
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
primitive_ids.clear();
|
||||
|
||||
// with line
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Line line = random_line();
|
||||
tree.all_intersected_primitives(line,std::back_inserter(primitive_ids));
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with line" << std::endl;
|
||||
primitive_ids.clear();
|
||||
|
||||
// with segment
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Segment segment = random_segment();
|
||||
tree.all_intersected_primitives(segment,std::back_inserter(primitive_ids));
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with segment" << std::endl;
|
||||
|
||||
// with segment
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Plane plane = random_plane();
|
||||
tree.all_intersected_primitives(plane,std::back_inserter(primitive_ids));
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with plane" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Scene::bench_do_intersect(Facet_tree& tree)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark do_intersect" << std::endl;
|
||||
|
||||
// with ray
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Ray ray = random_ray();
|
||||
tree.do_intersect(ray);
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
|
||||
// with line
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Line line = random_line();
|
||||
tree.do_intersect(line);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with line" << std::endl;
|
||||
|
||||
// with segment
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Segment segment = random_segment();
|
||||
tree.do_intersect(segment);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with segment" << std::endl;
|
||||
|
||||
// with plane
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Plane plane = random_plane();
|
||||
tree.do_intersect(plane);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with plane" << std::endl;
|
||||
}
|
||||
|
||||
void Scene::bench_nb_intersections(Facet_tree& tree)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark number_of_intersected_primitives" << std::endl;
|
||||
|
||||
// with ray
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Ray ray = random_ray();
|
||||
tree.number_of_intersected_primitives(ray);
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
|
||||
// with line
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Line line = random_line();
|
||||
tree.number_of_intersected_primitives(line);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with line" << std::endl;
|
||||
|
||||
// with segment
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Segment segment = random_segment();
|
||||
tree.number_of_intersected_primitives(segment);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with segment" << std::endl;
|
||||
|
||||
// with plane
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Plane plane = random_plane();
|
||||
tree.number_of_intersected_primitives(plane);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with plane" << std::endl;
|
||||
}
|
||||
|
||||
void Scene::bench_any_intersection(Facet_tree& tree)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark any_intersection" << std::endl;
|
||||
|
||||
// with ray
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Ray ray = random_ray();
|
||||
tree.any_intersection(ray);
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
|
||||
// with line
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Line line = random_line();
|
||||
tree.any_intersection(line);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with line" << std::endl;
|
||||
|
||||
// with segment
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Segment segment = random_segment();
|
||||
tree.any_intersection(segment);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with segment" << std::endl;
|
||||
|
||||
// with plane
|
||||
nb = 0;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Plane plane = random_plane();
|
||||
tree.any_intersection(plane);
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with plane" << std::endl;
|
||||
}
|
||||
|
||||
void Scene::bench_all_intersections(Facet_tree& tree)
|
||||
{
|
||||
std::list<Object_and_primitive_id> intersections;
|
||||
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark all_intersections" << std::endl;
|
||||
|
||||
// with ray
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
while(time.elapsed() < duration)
|
||||
{
|
||||
Ray ray = random_ray();
|
||||
tree.all_intersections(ray,std::back_inserter(intersections));
|
||||
switch(function)
|
||||
{
|
||||
case DO_INTERSECT:
|
||||
tree.do_intersect(ray);
|
||||
break;
|
||||
case ANY_INTERSECTION:
|
||||
tree.any_intersection(ray);
|
||||
break;
|
||||
case NB_INTERSECTIONS:
|
||||
tree.number_of_intersected_primitives(ray);
|
||||
break;
|
||||
case ALL_INTERSECTIONS:
|
||||
tree.all_intersections(ray,std::back_inserter(intersections));
|
||||
break;
|
||||
case ALL_INTERSECTED_PRIMITIVES:
|
||||
tree.all_intersected_primitives(ray,std::back_inserter(primitive_ids));
|
||||
break;
|
||||
}
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
intersections.clear();
|
||||
}
|
||||
|
||||
// with line
|
||||
nb = 0;
|
||||
void Scene::bench_intersection_lines(Facet_tree& tree,
|
||||
const int function,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
unsigned int nb = 0;
|
||||
std::list<Primitive_id> primitive_ids;
|
||||
std::list<Object_and_primitive_id> intersections;
|
||||
while(time.elapsed() < duration)
|
||||
{
|
||||
Line line = random_line();
|
||||
tree.all_intersections(line,std::back_inserter(intersections));
|
||||
switch(function)
|
||||
{
|
||||
case DO_INTERSECT:
|
||||
tree.do_intersect(line);
|
||||
break;
|
||||
case ANY_INTERSECTION:
|
||||
tree.any_intersection(line);
|
||||
break;
|
||||
case NB_INTERSECTIONS:
|
||||
tree.number_of_intersected_primitives(line);
|
||||
break;
|
||||
case ALL_INTERSECTIONS:
|
||||
tree.all_intersections(line,std::back_inserter(intersections));
|
||||
break;
|
||||
case ALL_INTERSECTED_PRIMITIVES:
|
||||
tree.all_intersected_primitives(line,std::back_inserter(primitive_ids));
|
||||
break;
|
||||
}
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with line" << std::endl;
|
||||
intersections.clear();
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
}
|
||||
|
||||
// with segment
|
||||
nb = 0;
|
||||
void Scene::bench_intersection_segments(Facet_tree& tree,
|
||||
const int function,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
unsigned int nb = 0;
|
||||
std::list<Primitive_id> primitive_ids;
|
||||
std::list<Object_and_primitive_id> intersections;
|
||||
while(time.elapsed() < duration)
|
||||
{
|
||||
Segment segment = random_segment();
|
||||
tree.all_intersections(segment,std::back_inserter(intersections));
|
||||
switch(function)
|
||||
{
|
||||
case DO_INTERSECT:
|
||||
tree.do_intersect(segment);
|
||||
break;
|
||||
case ANY_INTERSECTION:
|
||||
tree.any_intersection(segment);
|
||||
break;
|
||||
case NB_INTERSECTIONS:
|
||||
tree.number_of_intersected_primitives(segment);
|
||||
break;
|
||||
case ALL_INTERSECTIONS:
|
||||
tree.all_intersections(segment,std::back_inserter(intersections));
|
||||
break;
|
||||
case ALL_INTERSECTED_PRIMITIVES:
|
||||
tree.all_intersected_primitives(segment,std::back_inserter(primitive_ids));
|
||||
break;
|
||||
}
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with segment" << std::endl;
|
||||
intersections.clear();
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with ray" << std::endl;
|
||||
}
|
||||
|
||||
// with plane
|
||||
nb = 0;
|
||||
void Scene::bench_intersection_planes(Facet_tree& tree,
|
||||
const int function,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
while(time.elapsed() < 1000)
|
||||
unsigned int nb = 0;
|
||||
std::list<Primitive_id> primitive_ids;
|
||||
std::list<Object_and_primitive_id> intersections;
|
||||
while(time.elapsed() < duration)
|
||||
{
|
||||
Plane plane = random_plane();
|
||||
tree.all_intersections(plane,std::back_inserter(intersections));
|
||||
switch(function)
|
||||
{
|
||||
case DO_INTERSECT:
|
||||
tree.do_intersect(plane);
|
||||
break;
|
||||
case ANY_INTERSECTION:
|
||||
tree.any_intersection(plane);
|
||||
break;
|
||||
case NB_INTERSECTIONS:
|
||||
tree.number_of_intersected_primitives(plane);
|
||||
break;
|
||||
case ALL_INTERSECTIONS:
|
||||
tree.all_intersections(plane,std::back_inserter(intersections));
|
||||
break;
|
||||
case ALL_INTERSECTED_PRIMITIVES:
|
||||
tree.all_intersected_primitives(plane,std::back_inserter(primitive_ids));
|
||||
break;
|
||||
}
|
||||
nb++;
|
||||
}
|
||||
speed = 1000.0 * nb / time.elapsed();
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s with plane" << std::endl;
|
||||
}
|
||||
|
||||
void Scene::bench_do_intersect(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
std::cout << "Benchmark do_intersect" << std::endl;
|
||||
bench_intersection_segments(tree,DO_INTERSECT,duration);
|
||||
bench_intersection_rays(tree,DO_INTERSECT,duration);
|
||||
bench_intersection_lines(tree,DO_INTERSECT,duration);
|
||||
bench_intersection_planes(tree,DO_INTERSECT,duration);
|
||||
}
|
||||
|
||||
void Scene::bench_any_intersection(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
std::cout << "Benchmark any_intersection" << std::endl;
|
||||
bench_intersection_segments(tree,ANY_INTERSECTION,duration);
|
||||
bench_intersection_rays(tree,ANY_INTERSECTION,duration);
|
||||
bench_intersection_lines(tree,ANY_INTERSECTION,duration);
|
||||
bench_intersection_planes(tree,ANY_INTERSECTION,duration);
|
||||
}
|
||||
|
||||
void Scene::bench_nb_intersections(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
std::cout << "Benchmark nb_intersections" << std::endl;
|
||||
bench_intersection_segments(tree,DO_INTERSECT,duration);
|
||||
bench_intersection_rays(tree,DO_INTERSECT,duration);
|
||||
bench_intersection_lines(tree,DO_INTERSECT,duration);
|
||||
bench_intersection_planes(tree,DO_INTERSECT,duration);
|
||||
}
|
||||
|
||||
void Scene::bench_all_intersected_primitives(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
std::cout << "Benchmark all_intersected_primitives" << std::endl;
|
||||
bench_intersection_segments(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||
bench_intersection_rays(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||
bench_intersection_lines(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||
bench_intersection_planes(tree,ALL_INTERSECTED_PRIMITIVES,duration);
|
||||
}
|
||||
|
||||
void Scene::bench_all_intersections(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
std::cout << "Benchmark all_intersections" << std::endl;
|
||||
bench_intersection_segments(tree,ALL_INTERSECTIONS,duration);
|
||||
bench_intersection_rays(tree,ALL_INTERSECTIONS,duration);
|
||||
bench_intersection_lines(tree,ALL_INTERSECTIONS,duration);
|
||||
bench_intersection_planes(tree,ALL_INTERSECTIONS,duration);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// BENCH DISTANCES
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
void Scene::bench_squared_distance(Facet_tree& tree)
|
||||
void Scene::bench_distance(Facet_tree& tree,
|
||||
const int function,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < duration)
|
||||
{
|
||||
Point query = random_point();
|
||||
switch(function)
|
||||
{
|
||||
case SQ_DISTANCE:
|
||||
tree.squared_distance(query);
|
||||
break;
|
||||
case CLOSEST_POINT:
|
||||
tree.closest_point(query);
|
||||
break;
|
||||
case CLOSEST_POINT_AND_PRIMITIVE_ID:
|
||||
tree.closest_point_and_primitive(query);
|
||||
}
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s" << std::endl;
|
||||
}
|
||||
|
||||
void Scene::bench_squared_distance(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
std::cout << "Benchmark squared distance" << std::endl;
|
||||
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Point query = random_point();
|
||||
tree.squared_distance(query);
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s" << std::endl;
|
||||
bench_distance(tree,SQ_DISTANCE,duration);
|
||||
}
|
||||
|
||||
|
||||
void Scene::bench_closest_point(Facet_tree& tree)
|
||||
void Scene::bench_closest_point(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark closest point" << std::endl;
|
||||
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Point query = random_point();
|
||||
tree.closest_point(query);
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s" << std::endl;
|
||||
bench_distance(tree,CLOSEST_POINT,duration);
|
||||
}
|
||||
|
||||
void Scene::bench_closest_point_and_primitive(Facet_tree& tree)
|
||||
void Scene::bench_closest_point_and_primitive(Facet_tree& tree,
|
||||
const int duration)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
std::cout << "Benchmark closest point and primitive" << std::endl;
|
||||
|
||||
unsigned int nb = 0;
|
||||
while(time.elapsed() < 1000)
|
||||
{
|
||||
Point query = random_point();
|
||||
tree.closest_point_and_primitive(query);
|
||||
nb++;
|
||||
}
|
||||
double speed = 1000.0 * nb / time.elapsed();
|
||||
std::cout << speed << " queries/s" << std::endl;
|
||||
bench_distance(tree,CLOSEST_POINT_AND_PRIMITIVE_ID,duration);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue