From fa62ed3d9c906c3eff02b749b3fa077f5e82bdee Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Mon, 18 Oct 1999 15:42:28 +0000 Subject: [PATCH] Replaced selfmade timer by CGAL::Timer. --- .../Matrix_search/extremal_polygon_2_demo.C | 61 ++++++++++--------- .../rectangular_p_center_2_demo.C | 37 +++++------ 2 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Packages/Matrix_search/demo/Matrix_search/extremal_polygon_2_demo.C b/Packages/Matrix_search/demo/Matrix_search/extremal_polygon_2_demo.C index f78ca4486d2..f17bf7df5ec 100644 --- a/Packages/Matrix_search/demo/Matrix_search/extremal_polygon_2_demo.C +++ b/Packages/Matrix_search/demo/Matrix_search/extremal_polygon_2_demo.C @@ -54,6 +54,9 @@ #ifndef CGAL_RANDOM_CONVEX_SET_2_H #include #endif // CGAL_RANDOM_CONVEX_SET_2_H +#ifndef CGAL_TIMER_H +#include +#endif // CGAL_TIMER_H #ifndef CGAL_IO_LEDA_WINDOW_H #include #endif // CGAL_IO_LEDA_WINDOW_H @@ -63,6 +66,7 @@ #include using CGAL::cgalize; +using CGAL::Timer; using CGAL::has_smaller_dist_to_point; using CGAL::RED; using std::back_inserter; @@ -97,22 +101,7 @@ typedef PointCont::const_iterator Vertex_const_iterator; typedef vector< Vertex_iterator > Vertex_iteratorCont; typedef Vertex_iteratorCont::iterator Vertex_iteratorIter; -#ifdef EXTREMAL_POLYGON_MEASURE -#ifndef CGAL_PROTECT_CTIME -#include -#define CGAL_PROTECT_CTIME -#endif -static time_t Measure; -static long long int measure; -#define MEASURE(comm) \ - Measure = clock(); \ - comm; \ - measure = \ - (long long int)((float)(clock() - Measure) * 1000 / CLOCKS_PER_SEC); \ - cout << "[time: " << measure << " msec]" << endl; -#else -#define MEASURE(comm) comm -#endif + void wait_for_button_release( leda_window& W) { @@ -157,7 +146,7 @@ main() PointCont points; Polygon p; - bool polygon_changed( false); + bool polygon_changed(false); for (;;) { if (polygon_changed) { @@ -205,17 +194,25 @@ main() - if ( compute_mode != 1) { + if (compute_mode != 1) { // compute maximum area inscribed k-gon: - k = max( 3, k); + k = max(3, k); PointCont k_gon; - if ( p.size() >= 3) { - MEASURE(maximum_area_inscribed_k_gon( + if (p.size() >= 3) { +#ifdef EXTREMAL_POLYGON_MEASURE + Timer t; + t.start(); +#endif // EXTREMAL_POLYGON_MEASURE + maximum_area_inscribed_k_gon( p.begin(), p.end(), k, - back_inserter( k_gon));) - W.set_fg_color( leda_green); + back_inserter(k_gon)); +#ifdef EXTREMAL_POLYGON_MEASURE + t.stop(); + cout << "[time: " << t.time() << " msec]" << endl; +#endif // EXTREMAL_POLYGON_MEASURE + W.set_fg_color(leda_green); if ( !p.empty()) { PointIter i( k_gon.begin()); while ( ++i != k_gon.end()) @@ -224,22 +221,30 @@ main() } // if ( !p.empty()) } // if ( p.size() >= 3) } // if ( compute_mode != 1) - if ( compute_mode != 0) { + if (compute_mode != 0) { // compute maximum perimeter inscribed k-gon: PointCont k_gon; +#ifdef EXTREMAL_POLYGON_MEASURE + Timer t; + t.start(); +#endif // EXTREMAL_POLYGON_MEASURE #ifndef CGAL_CFG_NO_MEMBER_TEMPLATES - MEASURE(maximum_perimeter_inscribed_k_gon( + maximum_perimeter_inscribed_k_gon( Vertex_circulator( &p), Vertex_circulator( &p), k, - back_inserter( k_gon));) + back_inserter( k_gon)); #else - MEASURE(maximum_perimeter_inscribed_k_gon( + maximum_perimeter_inscribed_k_gon( p.begin(), p.end(), k, - back_inserter( k_gon));) + back_inserter( k_gon)); #endif +#ifdef EXTREMAL_POLYGON_MEASURE + t.stop(); + cout << "[time: " << t.time() << " msec]" << endl; +#endif // EXTREMAL_POLYGON_MEASURE W.set_fg_color( leda_orange); if ( !p.empty()) { PointIter i( k_gon.begin()); diff --git a/Packages/Matrix_search/demo/Matrix_search/rectangular_p_center_2_demo.C b/Packages/Matrix_search/demo/Matrix_search/rectangular_p_center_2_demo.C index c0398ca0ab4..65ad6eeae92 100644 --- a/Packages/Matrix_search/demo/Matrix_search/rectangular_p_center_2_demo.C +++ b/Packages/Matrix_search/demo/Matrix_search/rectangular_p_center_2_demo.C @@ -57,6 +57,9 @@ #ifndef CGAL_ALGORITHM_H #include #endif // CGAL_ALGORITHM_H +#ifndef CGAL_TIMER_H +#include +#endif // CGAL_TIMER_H #include #include #include @@ -85,6 +88,7 @@ using CGAL::Istream_iterator; using CGAL::Ostream_iterator; using CGAL::set_pretty_mode; using CGAL::cgalize; +using CGAL::Timer; using CGAL::BLUE; using CGAL::RED; using CGAL::ORANGE; @@ -192,21 +196,6 @@ typedef Istream_iterator< Point, leda_window> -#include -static time_t Measure; -static long long int measure; -#define MEASURE(comm) \ -Measure = clock(); \ - comm; \ - measure = (long long int)((float)(clock() - Measure) \ - * 1000 / CLOCKS_PER_SEC); \ - cerr << "[time: " << measure << " msec]\n"; -#define MEASURE_NO_OUTPUT(comm) \ -Measure = clock(); \ - comm; \ - measure = (long long int)((float)(clock() - Measure) \ - * 1000 / CLOCKS_PER_SEC); - // function class to construct a box // around a point p with radius r template < class Point, class FT, class Box > @@ -328,14 +317,16 @@ main(int argc, char* argv[]) W << GREEN << CGAL::bounding_box_2(input_points.begin(), input_points.end()); #endif // CGAL_PCENTER_NO_SHOW - MEASURE( - rectangular_p_center_2( - input_points.begin(), - input_points.end(), - back_inserter(centers), - result, - number_of_clusters); - ) + Timer t; + t.start(); + rectangular_p_center_2( + input_points.begin(), + input_points.end(), + back_inserter(centers), + result, + number_of_clusters); + t.stop(); + cout << "[time: " << t.time() << " msec]" << endl; int number_of_piercing_points(centers.size()); cerr << "Finished with diameter " << result << " and " << number_of_piercing_points