diff options
author | Lloyd Sheng <i@lloydsheng.com> | 2018-06-21 11:24:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-21 11:24:14 +0800 |
commit | eb70b8984901d8113f3a29d26cc355d5b3ed46fd (patch) | |
tree | 258ea32e9e7b9a29f3c861d83bc0674fd2a21603 /src/mbgl/util | |
parent | 2886aca3e29660df24ea4a089b1a4457404cdf75 (diff) | |
download | qtlocation-mapboxgl-eb70b8984901d8113f3a29d26cc355d5b3ed46fd.tar.gz |
[core] Measuring tiles requesting/parsing time using logging (#12152)
* Tile timing
* Refactor logging code
* Keep the scope of `messageStream` constrained
* Make log message more clear
* Fix crash issue if onlineResponse.data is null
Diffstat (limited to 'src/mbgl/util')
-rw-r--r-- | src/mbgl/util/event.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/util/stopwatch.hpp | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/mbgl/util/event.cpp b/src/mbgl/util/event.cpp index 3a3be20f5c..0c08d72a8c 100644 --- a/src/mbgl/util/event.cpp +++ b/src/mbgl/util/event.cpp @@ -28,6 +28,7 @@ MBGL_DEFINE_ENUM(Event, { { Event::Android, "Android" }, { Event::Crash, "Crash" }, { Event::Glyph, "Glyph" }, + { Event::Timing, "Timing" }, { Event(-1), "Unknown" }, }); 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 { |