summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnur Nigmetov <a.nigmetov@gmail.com>2017-04-24 17:12:46 +0200
committerArnur Nigmetov <a.nigmetov@gmail.com>2017-04-24 17:12:46 +0200
commitad723189c90c37ffdba34c2db5c764ceb2192086 (patch)
tree03b976b2c47812087534a4a18cb17a1f69c778b7
parent24549c23156d612be2859583489f155bf8567008 (diff)
Verbose timing for bottleneck added
Timing info is printed, if VERBOSE_BOTTLENECK is #defined in def_debug_bt.h.
-rw-r--r--geom_bottleneck/bottleneck/include/def_debug_bt.h1
-rw-r--r--geom_bottleneck/bottleneck/src/bottleneck.cpp11
-rw-r--r--geom_bottleneck/bottleneck/src/bound_match.cpp19
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<double, double> 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<double, double> 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 <http://www.gnu.org/licenses/>.
#include <assert.h>
#include "def_debug_bt.h"
#include "bound_match.h"
+
+#ifdef VERBOSE_BOTTLENECK
+#include <chrono>
+#endif
+
#ifndef FOR_R_TDA
#include <iostream>
#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<std::chrono::high_resolution_clock> startMoment;
+ startMoment = hrClock.now();
+#endif
+ bool result = buildMatchingForThreshold(r);
+#ifdef VERBOSE_BOTTLENECK
+ auto endMoment = hrClock.now();
+ std::chrono::duration<double, std::milli> iterTime = endMoment - startMoment;
+ std::cout << "isMatchLess for r = " << r << " finished in " << std::chrono::duration<double, std::milli>(iterTime).count() << " ms." << std::endl;
+#endif
+ return result;
+
}