From 3620b34a68c0fe54cd15704e172da65d3c86d3aa Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Thu, 4 Oct 2018 11:33:52 +0300 Subject: [PATCH] Added distribution --- drape_frontend/drape_measurer.cpp | 27 ++++++++++++++++++++++++++- drape_frontend/drape_measurer.hpp | 7 ++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drape_frontend/drape_measurer.cpp b/drape_frontend/drape_measurer.cpp index 4d05328a5e..bf1d24d263 100644 --- a/drape_frontend/drape_measurer.cpp +++ b/drape_frontend/drape_measurer.cpp @@ -1,5 +1,7 @@ #include "drape_frontend/drape_measurer.hpp" +#include + namespace df { DrapeMeasurer & DrapeMeasurer::Instance() @@ -42,6 +44,7 @@ void DrapeMeasurer::StartBenchmark() m_totalTPFCount = 0; m_minFPS = std::numeric_limits::max(); + m_fpsDistribution.clear(); m_totalFPS = 0.0; m_totalFPSCount = 0; #endif @@ -149,6 +152,15 @@ std::string DrapeMeasurer::RenderStatistic::ToString() const ss << " FPS = " << m_FPS << "\n"; ss << " min FPS = " << m_minFPS << "\n"; ss << " Frame render time, ms = " << m_frameRenderTimeInMs << "\n"; + if (!m_fpsDistribution.empty()) + { + ss << " FPS Distribution:\n"; + for (auto const & fps : m_fpsDistribution) + { + ss << " " << fps.first << "-" << (fps.first + 10) << ": " << std::setprecision(4) + << fps.second * 100.0f << "%\n"; + } + } ss << " ----- Render statistic report ----- \n"; return ss.str(); @@ -159,11 +171,21 @@ DrapeMeasurer::RenderStatistic DrapeMeasurer::GetRenderStatistic() using namespace std::chrono; RenderStatistic statistic; - statistic.m_FPS = m_totalFPS / m_totalFPSCount; + statistic.m_FPS = static_cast(m_totalFPS / m_totalFPSCount); statistic.m_minFPS = m_minFPS; statistic.m_frameRenderTimeInMs = static_cast(duration_cast(m_totalTPF).count()) / m_totalTPFCount; + uint32_t totalCount = 0; + for (auto const & fps : m_fpsDistribution) + totalCount += fps.second; + + if (totalCount != 0) + { + for (auto const & fps : m_fpsDistribution) + statistic.m_fpsDistribution[fps.first] = static_cast(fps.second) / totalCount; + } + return statistic; } #endif @@ -199,6 +221,9 @@ void DrapeMeasurer::AfterRenderFrame() m_totalTPF += m_totalFrameRenderTime / m_totalFramesCount; ++m_totalTPFCount; + + auto const fpsGroup = (static_cast(fps) / 10) * 10; + m_fpsDistribution[fpsGroup]++; #endif m_totalFramesCount = 0; diff --git a/drape_frontend/drape_measurer.hpp b/drape_frontend/drape_measurer.hpp index b64d46e1ee..f35d8f5217 100644 --- a/drape_frontend/drape_measurer.hpp +++ b/drape_frontend/drape_measurer.hpp @@ -13,10 +13,10 @@ #include #include #include +#include namespace df { - class DrapeMeasurer { public: @@ -33,6 +33,7 @@ public: uint32_t m_FPS = 0; uint32_t m_minFPS = 0; uint32_t m_frameRenderTimeInMs = 0; + std::map m_fpsDistribution; }; RenderStatistic GetRenderStatistic(); @@ -155,6 +156,7 @@ private: uint32_t m_minFPS = std::numeric_limits::max(); double m_totalFPS = 0.0; uint32_t m_totalFPSCount = 0; + std::unordered_map m_fpsDistribution; #endif #if defined(RENDER_STATISTIC) || defined(TRACK_GPU_MEM) @@ -171,5 +173,4 @@ private: uint32_t m_numberOfSnapshots = 0; #endif }; - -} +} // namespace df