summaryrefslogtreecommitdiff
path: root/src/mbgl/util/stopwatch.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/util/stopwatch.hpp')
-rw-r--r--src/mbgl/util/stopwatch.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/mbgl/util/stopwatch.hpp b/src/mbgl/util/stopwatch.hpp
index 6214dae958..0c91342a57 100644
--- a/src/mbgl/util/stopwatch.hpp
+++ b/src/mbgl/util/stopwatch.hpp
@@ -4,9 +4,24 @@
#include <mbgl/util/chrono.hpp>
#include <string>
+#include <sstream>
namespace mbgl {
namespace util {
+
+#ifdef MBGL_TIMING
+// Declare 'watch' as a shared_ptr so it can be captured by value in a lambda function
+#define MBGL_TIMING_START(watch) std::shared_ptr<util::stopwatch> watch = std::make_unique<util::stopwatch>(Event::Timing);
+#define MBGL_TIMING_FINISH(watch, message) \
+ do { \
+ std::stringstream messageStream; \
+ messageStream << message; \
+ watch->report(messageStream.str()); \
+ } while (0);
+#else
+#define MBGL_TIMING_START(watch)
+#define MBGL_TIMING_FINISH(watch, message)
+#endif
#ifndef DISABLE_STOPWATCH
class stopwatch {