From 3ba7c3f1d0298306af37471027a5fc9e204ece8c Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Wed, 11 Nov 2015 20:24:10 +0200 Subject: db: print slowest frame time --- tests/db.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/db.cpp b/tests/db.cpp index 4356e97..4a7846c 100644 --- a/tests/db.cpp +++ b/tests/db.cpp @@ -105,7 +105,8 @@ public: void start_flipping() { - m_t1 = std::chrono::steady_clock::now(); + m_time_last = m_t1 = std::chrono::steady_clock::now(); + m_slowest_frame = std::chrono::duration::min(); m_frame_num = 0; queue_next(); } @@ -115,13 +116,23 @@ private: { ++m_frame_num; + auto now = std::chrono::steady_clock::now(); + + std::chrono::duration diff = now - m_time_last; + if (diff > m_slowest_frame) + m_slowest_frame = diff; + if (m_frame_num % 100 == 0) { - auto t2 = std::chrono::steady_clock::now(); - std::chrono::duration fsec = t2 - m_t1; - printf("Output %d: fps %f\n", m_connector->idx(), 100.0 / fsec.count()); - m_t1 = t2; + std::chrono::duration fsec = now - m_t1; + printf("Output %d: fps %f, slowest %.2f ms\n", + m_connector->idx(), 100.0 / fsec.count(), + m_slowest_frame.count() * 1000); + m_t1 = now; + m_slowest_frame = std::chrono::duration::min(); } + m_time_last = now; + queue_next(); } @@ -167,6 +178,8 @@ private: int m_frame_num; chrono::steady_clock::time_point m_t1; + chrono::steady_clock::time_point m_time_last; + chrono::duration m_slowest_frame; Flipper m_flipper; -- cgit v1.2.3