add code to benchmark to test specific situations

This commit is contained in:
Sébastien Loriot 2012-05-31 12:59:50 +00:00
parent cf9a4e8742
commit 6b51332818
1 changed files with 36 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#define bench(METHOD,CONTAINER) \
{\
std::size_t previous=0;\
unsigned run=0;\
CGAL::Timer time;\
do{\
@ -21,6 +22,8 @@
time.start();\
METHOD( CONTAINER.begin(), CONTAINER.end(), std::back_inserter(result) );\
time.stop();\
if( previous!=0 && previous!=result.size()) std::cerr << "error got different result" << std::endl;\
previous=result.size();\
}while(++run<repeat+1);\
std::cout << result.size() << " points on the convex hull using "<< #METHOD << "; Done in "<< time.time() << "s\n";\
}
@ -37,6 +40,7 @@ int main(int argc, char** argv)
unsigned seed=0;
if (argc>1) nbpts=atoi(argv[1]);
if (argc>2) repeat=atoi(argv[2]);
if (argc>3) seed=atoi(argv[3]);
@ -46,6 +50,38 @@ int main(int argc, char** argv)
CGAL::Random_points_in_disc_2<Point_2,Creator> g( 150.0,r);
CGAL::cpp0x::copy_n( g, nbpts, std::back_inserter(points));
//the following code is for testing when there is only two extreme points, affine hull is 2D
/*
CGAL::Bbox_2 bbox=points.begin()->bbox();
for (Points::iterator it=points.begin();it!=points.end();++it)
bbox=bbox+it->bbox();
points.push_back( Point_2(bbox.xmin()-1,bbox.ymin()-1) );
points.push_back( Point_2(bbox.xmax()+1,bbox.ymax()+1) );
*/
//the following code is for testing when there is only three extreme points
/*
CGAL::Bbox_2 bbox=points.begin()->bbox();
for (Points::iterator it=points.begin();it!=points.end();++it)
bbox=bbox+it->bbox();
points.push_back( Point_2(bbox.xmin()-1,bbox.ymin()-1) );
points.push_back( Point_2(bbox.xmax()+1,bbox.ymax()+1) );
points.push_back( Point_2(bbox.xmax(),bbox.ymax()+2) );
*/
//the following code is for testing when there is only two extreme points, affine hull is 1D
/*
points.clear();
for (unsigned i=0;i<nbpts;++i)
points.push_back(Point_2(i,i));
*/
std::cout << "seed is " << seed << "; using " << nbpts << " pts; on " << repeat+1 << " run(s).\n";
std::cout << "Using vector" << std::endl;