summaryrefslogtreecommitdiff
path: root/src/mbgl/util/stopwatch.hpp
diff options
context:
space:
mode:
authorLloyd Sheng <i@lloydsheng.com>2018-06-19 17:17:12 +0800
committerLloyd Sheng <i@lloydsheng.com>2018-06-19 17:17:12 +0800
commitd0fd03225f5df28b349320e4c7f328baa43522c5 (patch)
treef3f4a81178ea1f622b3e6d3a376437a896b1dec1 /src/mbgl/util/stopwatch.hpp
parentbc02a43c67c5365feac95ff551cd1a250754d707 (diff)
downloadqtlocation-mapboxgl-d0fd03225f5df28b349320e4c7f328baa43522c5.tar.gz
Refactor logging code
Diffstat (limited to 'src/mbgl/util/stopwatch.hpp')
-rw-r--r--src/mbgl/util/stopwatch.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mbgl/util/stopwatch.hpp b/src/mbgl/util/stopwatch.hpp
index 6214dae958..0782aa742f 100644
--- a/src/mbgl/util/stopwatch.hpp
+++ b/src/mbgl/util/stopwatch.hpp
@@ -4,9 +4,21 @@
#include <mbgl/util/chrono.hpp>
#include <string>
+#include <sstream>
namespace mbgl {
namespace util {
+
+#ifdef MBGL_TIMING
+#define MBGL_TIMING_START(watch) std::shared_ptr<util::stopwatch> watch = std::make_unique<util::stopwatch>(Event::Timing);
+#define MBGL_TIMING_FINISH(watch, message) \
+ std::stringstream messageStream; \
+ messageStream << message; \
+ watch->report(messageStream.str());
+#else
+#define MBGL_TIMING_START(watch)
+#define MBGL_TIMING_FINISH(watch, message)
+#endif
#ifndef DISABLE_STOPWATCH
class stopwatch {