From ad723189c90c37ffdba34c2db5c764ceb2192086 Mon Sep 17 00:00:00 2001 From: Arnur Nigmetov Date: Mon, 24 Apr 2017 17:12:46 +0200 Subject: Verbose timing for bottleneck added Timing info is printed, if VERBOSE_BOTTLENECK is #defined in def_debug_bt.h. --- geom_bottleneck/bottleneck/include/def_debug_bt.h | 1 + geom_bottleneck/bottleneck/src/bottleneck.cpp | 11 ++++++++--- geom_bottleneck/bottleneck/src/bound_match.cpp | 19 ++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/geom_bottleneck/bottleneck/include/def_debug_bt.h b/geom_bottleneck/bottleneck/include/def_debug_bt.h index 60f834e..888ded6 100644 --- a/geom_bottleneck/bottleneck/include/def_debug_bt.h +++ b/geom_bottleneck/bottleneck/include/def_debug_bt.h @@ -29,5 +29,6 @@ // for R package TDA, to comply with some CRAN rules // like no usage of cout, cerr, cin, exit, etc. //#define FOR_R_TDA +//#define VERBOSE_BOTTLENECK #endif diff --git a/geom_bottleneck/bottleneck/src/bottleneck.cpp b/geom_bottleneck/bottleneck/src/bottleneck.cpp index da0c425..f90e5c9 100644 --- a/geom_bottleneck/bottleneck/src/bottleneck.cpp +++ b/geom_bottleneck/bottleneck/src/bottleneck.cpp @@ -208,10 +208,15 @@ std::pair bottleneckDistApproxIntervalHeur(DiagramPointSet& A, D DiagramPointSet sampledA, sampledB; sampleDiagramForHeur(A, sampledA); sampleDiagramForHeur(B, sampledB); - //std::cout << "A : " << A.size() << ", sampled: " << sampledA.size() << std::endl; - //std::cout << "B : " << B.size() << ", sampled: " << sampledB.size() << std::endl; +#ifdef VERBOSE_BOTTLENECK + std::cout << "A : " << A.size() << ", sampled: " << sampledA.size() << std::endl; + std::cout << "B : " << B.size() << ", sampled: " << sampledB.size() << std::endl; +#endif std::pair initGuess = bottleneckDistApproxInterval(sampledA, sampledB, epsilon); - //std::cout << "initial guess: " << initGuess.first << ", " << initGuess.second << std::endl; +#ifdef VERBOSE_BOTTLENECK + std::cout << "initial guess with sampling: " << initGuess.first << ", " << initGuess.second << std::endl; + std::cout << "running on the original diagrams" << std::endl; +#endif return bottleneckDistApproxIntervalWithInitial(A, B, epsilon, initGuess); } diff --git a/geom_bottleneck/bottleneck/src/bound_match.cpp b/geom_bottleneck/bottleneck/src/bound_match.cpp index a9ec93a..a95ee60 100644 --- a/geom_bottleneck/bottleneck/src/bound_match.cpp +++ b/geom_bottleneck/bottleneck/src/bound_match.cpp @@ -21,6 +21,11 @@ along with GeomBottleneck. If not, see . #include #include "def_debug_bt.h" #include "bound_match.h" + +#ifdef VERBOSE_BOTTLENECK +#include +#endif + #ifndef FOR_R_TDA #include #endif @@ -245,7 +250,19 @@ BoundMatchOracle::BoundMatchOracle(DiagramPointSet psA, DiagramPointSet psB, bool BoundMatchOracle::isMatchLess(double r) { - return buildMatchingForThreshold(r); +#ifdef VERBOSE_BOTTLENECK + std::chrono::high_resolution_clock hrClock; + std::chrono::time_point startMoment; + startMoment = hrClock.now(); +#endif + bool result = buildMatchingForThreshold(r); +#ifdef VERBOSE_BOTTLENECK + auto endMoment = hrClock.now(); + std::chrono::duration iterTime = endMoment - startMoment; + std::cout << "isMatchLess for r = " << r << " finished in " << std::chrono::duration(iterTime).count() << " ms." << std::endl; +#endif + return result; + } -- cgit v1.2.3