[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
This commit is contained in:
Lloyd Sheng
2018-06-21 11:24:14 +08:00
committed by GitHub
parent 2886aca3e2
commit eb70b89849
5 changed files with 40 additions and 0 deletions

View File

@@ -11,6 +11,7 @@
#include <mbgl/util/url.hpp>
#include <mbgl/util/thread.hpp>
#include <mbgl/util/work_request.hpp>
#include <mbgl/util/stopwatch.hpp>
#include <cassert>
@@ -151,8 +152,17 @@ public:
// Get from the online file source
if (resource.hasLoadingMethod(Resource::LoadingMethod::Network)) {
MBGL_TIMING_START(watch);
tasks[req] = onlineFileSource.request(resource, [=] (Response onlineResponse) mutable {
this->offlineDatabase->put(resource, onlineResponse);
if (resource.kind == Resource::Kind::Tile) {
// onlineResponse.data will be null if data not modified
MBGL_TIMING_FINISH(watch,
" Action: " << "Requesting," <<
" URL: " << resource.url.c_str() <<
" Size: " << (onlineResponse.data != nullptr ? onlineResponse.data->size() : 0) << "B," <<
" Time")
}
callback(onlineResponse);
});
}