From 7b73d971fa7bd7f2633d6f9447a39cdf089740ba Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 19 Aug 2016 23:15:37 +0300 Subject: [node] stopwatch --- platform/default/headless_view.cpp | 20 ++++++++++++++------ src/mbgl/map/map.cpp | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/platform/default/headless_view.cpp b/platform/default/headless_view.cpp index 28c300b41e..945de32037 100644 --- a/platform/default/headless_view.cpp +++ b/platform/default/headless_view.cpp @@ -1,5 +1,6 @@ -#include #include +#include +#include #include #include @@ -41,21 +42,28 @@ void HeadlessView::resize(const uint16_t width, const uint16_t height) { } PremultipliedImage HeadlessView::readStillImage() { + util::stopwatch stopwatch("readStillImage", Event::General); assert(active); const unsigned int w = dimensions[0] * pixelRatio; const unsigned int h = dimensions[1] * pixelRatio; PremultipliedImage image { w, h }; - MBGL_CHECK_ERROR(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get())); + { + util::stopwatch stopwatch2("glReadPixels", Event::General); + MBGL_CHECK_ERROR(glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, image.data.get())); + } const auto stride = image.stride(); auto tmp = std::make_unique(stride); uint8_t* rgba = image.data.get(); - for (int i = 0, j = h - 1; i < j; i++, j--) { - std::memcpy(tmp.get(), rgba + i * stride, stride); - std::memcpy(rgba + i * stride, rgba + j * stride, stride); - std::memcpy(rgba + j * stride, tmp.get(), stride); + { + util::stopwatch stopwatch3("memcpy", Event::General); + for (int i = 0, j = h - 1; i < j; i++, j--) { + std::memcpy(tmp.get(), rgba + i * stride, stride); + std::memcpy(rgba + i * stride, rgba + j * stride, stride); + std::memcpy(rgba + j * stride, tmp.get(), stride); + } } return image; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 3a307735ab..eab4c77e2e 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include namespace mbgl { @@ -241,6 +242,7 @@ void Map::Impl::update() { if (mode == MapMode::Continuous) { view.invalidate(); } else if (callback && style->isLoaded()) { + util::stopwatch stopwatch2("render", Event::General); view.activate(); render(); view.deactivate(); -- cgit v1.2.1