#ifndef ECG_BENCH_H #define ECG_BENCH_H #include #include #include #include #include #include #include #include #include "Input_data.h" #include #include class Bench { private: int numof_f_fails; std::ofstream htmlout,texout; struct rusage before,after; struct timeval utime,stime; bool firsttime; int vert[4],hedg[4]; int i; typedef std::size_t size_type; CGAL::Memory_sizer mem_sizer; std::string Dxffile; bool ONLY_DXF; double MemBefore,MemAfter; public: Bench(const bool only_dxf=false, const char *fhtml="benchmarks.html", const char* ftex="benchmarks.tex",const char* Dxffilename=""): htmlout(fhtml,std::ios::app), texout(ftex,std::ios::app){ i=0; numof_f_fails= 0; Dxffile=Dxffilename; ONLY_DXF = only_dxf; std::cout << ".:Starting Bench Suite:." << std::endl; htmlout<<"Dxf file is : "<< Dxffile << std::endl; htmlout<<""<" <" <"<"; texout<<" "; } void close_cell(){ htmlout <<""; texout <<" "; } void open_row(){ htmlout <<""; texout <<""; } void close_row(){ htmlout <<""<< std::endl; texout <<"\\\\ \\hline"<< std::endl; } void empty_cell(){ this->open_cell(); htmlout << "
Kernelgrid I(400 Circle_2)grid II(800 Circle_2)random double (100 Circle) rotation (125 Circle_2)
KernelDxf input is: "<< Dxffile <<"
" << std::endl << "" << "
User timeNum. of failsverticeshalfedgesMemBeforeMemAfter
" <<"-"<<"" <<"-"<< "" <<"-"<< "" <<"-"<< "" <<"-"<< "" <<"-"<< "
" ; texout<<"& -& -&-& -"; this->close_cell(); } void start(void){ getrusage(RUSAGE_SELF,&before); } void stop(void){ getrusage(RUSAGE_SELF,&after); } void summarize(int vertices,int hedges){ int temp; // temp=CGAL::Interval_nt<>::number_of_failures(); numof_f_fails = temp - numof_f_fails; std::cout << " numbers_of_filter_fails : " << numof_f_fails << std::endl; timersub(&(after.ru_utime),&(before.ru_utime),&utime); timersub(&(after.ru_stime),&(before.ru_stime),&stime); htmlout << "" << std::endl << "" << "
User timeNum. of failsverticeshalfedgesMemBeforeMemAfter
" <" << numof_f_fails << "" << vertices << "" << hedges<<"" << MemBefore << "" << MemAfter<< "
"; texout << " & " <::number_of_failures(); } void fail(void){ htmlout << ""<" << "
User timeNum. of failsverticeshalfedgesMemBeforeMemAfter" <<"fail"<<"" <<"fail"<< "" <<"fail"<< "" <<"fail"<< "" <<"fail"<< "" <<"fail"<< "
" ; texout << "& fail & fail & fail & fail"; std::cout << " :: Abort:: "<< std::endl; } template void arrangement(const ArcContainer & ac){ bool fail=false; typedef typename CGAL::Arrangement_2 Pmwx; typedef typename CGAL::Arr_naive_point_location Point_location; std::cout << "memory size before construction" << mem_sizer.virtual_size() << std::endl; std::cout << "memory resident size before insert()" << mem_sizer.resident_size () << std::endl; MemBefore = mem_sizer.virtual_size ()/1000000; Pmwx _pm; Point_location _pl(_pm); try{ this->start(); insert(_pm,ac.begin(),ac.end(),std::false_type()); this->stop(); } catch (std::exception &e) { this->fail(); std::cout << "Exception:" << std::endl << e.what() << std::endl; fail=true; } catch(...) { this->fail(); fail=true; } vert[i]=(int)_pm.number_of_vertices(); hedg[i]=(int)_pm.number_of_halfedges(); if (!fail){this->summarize(_pm.number_of_vertices(),_pm.number_of_halfedges());} MemAfter = mem_sizer.virtual_size ()/1000000; std::cout << "memory size after insert()" << mem_sizer.virtual_size () << std::endl; std::cout << "memory resident size after insert()" << mem_sizer.resident_size () << std::endl; _pm.clear(); } template void grid(){ i=1; ArcContainer ac; _bench_input_grid(ac); this->open_cell(); this->arrangement(ac); this->close_cell(); } template void grid2(){ i=2; ArcContainer ac; _bench_input_grid2(ac); this->open_cell(); this->arrangement(ac); this->close_cell(); } template void random(){ i=3; ArcContainer ac; if (firsttime){ _bench_input_random(ac); std::cout << "Input from random generator!"<(ac); std::cout << "Input from file!"<open_cell(); this->arrangement(ac); this->close_cell(); firsttime = false; } template void dfx(const char* Dfxfile){ i=4; ArcContainer arc; _bench_input_dfx(arc,Dfxfile); this->open_cell(); this->arrangement(arc); this->close_cell(); } template void rotation(){ i=5; bool fail=false; ArcContainer arc; try{ _bench_input_rotation(arc); } catch (...) { this->fail(); fail=true; std::cout << "failed before input"; } if (!fail){ this->open_cell(); this->arrangement(arc); this->close_cell(); this->close_row(); } } public: template void Compute(const char* dxffile){ if(!ONLY_DXF){ this->grid(); this->grid2(); this->random(); this->dfx(dxffile); this->rotation(); } else{ this->dfx(dxffile); this->close_row(); } } template void Compute_no_dxf(){ if(!ONLY_DXF){ this->grid(); this->grid2(); this->random(); //this->empty_cell(); this->rotation(); } } void empty_row(){ this->empty_cell(); this->empty_cell(); this->empty_cell(); this->empty_cell(); this->empty_cell(); this->close_row(); } template void Compute_dxf(const char* dxffile){ this->dfx(dxffile); this->close_row(); } void kernel(const char* kernel){ this->open_row(); this->open_cell(); htmlout << kernel; texout << kernel ; this->close_cell(); } void newDxfFilename(const char* Dxffilename=""){ const char* newDxf = Dxffilename; if(!ONLY_DXF){ htmlout<< "Kernelgrid Igrid IIrandom doubleDxf input is: "<< newDxf <<" rotation " <KernelDxf input is: "<< newDxf <<" " <