diff --git a/Packages/Curved_kernel/Benchmarks/DxfArrayBenchmarks/benchmark.h b/Packages/Curved_kernel/Benchmarks/DxfArrayBenchmarks/benchmark.h new file mode 100644 index 00000000000..81bf74a21f2 --- /dev/null +++ b/Packages/Curved_kernel/Benchmarks/DxfArrayBenchmarks/benchmark.h @@ -0,0 +1,466 @@ +#ifndef ECG_BENCH_H +#define ECG_BENCH_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include "Input_data.h" +#include "boost/variant.hpp" + + + +class Bench +{ +private: + + int numof_f_fails; + std::ofstream htmlout,texout; + struct rusage before,after; + struct timeval utime,stime; + bool firsttime; + int vert[5],hedg[5]; + int i; + CGAL::Memory_sizer mem_sizer; + char* Dxffile; + bool ONLY_DXF; + typedef std::list DxfFileNames; + bool Dxf_Horizontal; + double MemBefore,MemAfter; +public: + Bench(DxfFileNames df,char * fhtml="benchmarks.html", char* ftex="benchmarks.tex"): + htmlout(fhtml,std::ios::app), + texout(ftex,std::ios::app) + { + i=0; + numof_f_fails= CGAL::Interval_nt<>::number_of_failures() ; + ONLY_DXF = false; + Dxf_Horizontal =true; + std::cout << ".:Starting Bench Suite:." << std::endl; + std::cout << ".:Starting Bench Suite:." << std::endl; + + htmlout<<""<"; + texout << "\\documentclass[1pt]{article}"<"<<*it<<""; + texout <<"& \\multicolumn{4}{c|}{\\begin{verbatim}"<< *it<<"\\end{verbatim}}"; + }; + htmlout << "" + <::number_of_failures(); + Dxffile=Dxffilename; + ONLY_DXF = only_dxf; + + std::cout << ".:Starting Bench Suite:." << std::endl; + + htmlout<<"Dxf file is : "<< Dxffile << std::endl; + + htmlout<<"
Kernel
"<" + <" + <"<"; + 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_curves()" << mem_sizer.resident_size () << std::endl; + MemBefore = mem_sizer.virtual_size ()/1000; + Pmwx _pm; + Point_location _pl(_pm); + + try{ + this->start(); + insert_curves(_pm,ac.begin(),ac.end()); + this->stop(); + } + 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 ()/1000; + std::cout << "memory size after insert_curves()" << mem_sizer.virtual_size () << std::endl; + std::cout << "memory resident size after insert_curves()" << 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(char* Dfxfile){ + if(!Dxf_Horizontal){ + 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(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 ComputeArrayDxf(DxfFileNames df){ + i=0; + for ( DxfFileNames::const_iterator it=df.begin(); + it != df.end(); ++it) { + std::cout<<*it<dfx(*it); + i++; + }; + 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(char* dxffile){ + this->dfx(dxffile); + this->close_row(); + } + + void kernel(char* kernel){ + this->open_row(); + this->open_cell(); + htmlout << kernel; + texout << kernel ; + this->close_cell(); + } + + + void newDxfFilename(char* Dxffilename=""){ + char* newDxf = Dxffilename; + if(!Dxf_Horizontal){ + if(!ONLY_DXF){ + htmlout<< "Kernelgrid Igrid IIrandom doubleDxf input is: "<< newDxf <<" rotation " + <KernelDxf input is: "<< newDxf <<" " + <"<"<"<Kernel"; + for (DxfFileNames::const_iterator it=df.begin(); + it != df.end(); ++it) { + std::cout<<*it<"<<*it<<""; + texout <<"& \\multicolumn{4}{c|}{\\begin{verbatim}"<< *it<<"\\end{verbatim}}"; + }; + htmlout << "" + <