]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/blobdiff - tests/db.cpp
db: print slowest frame time
[android/external-libkmsxx.git] / tests / db.cpp
index ada85e0786e7d8e72d8a0a25094d9e1ffaeedd46..4a7846cb5ce47d1bbe0b6a645190830fe5f50ccf 100644 (file)
@@ -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<float>::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<float> 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<float> fsec = t2 - m_t1;
-                       printf("Output %d: fps %f\n", m_connector->idx(), 100.0 / fsec.count());
-                       m_t1 = t2;
+                       std::chrono::duration<float> 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<float>::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<float> m_slowest_frame;
 
        Flipper m_flipper;
 
@@ -181,8 +194,6 @@ int main()
        if (card.master() == false)
                printf("Not DRM master, modeset may fail\n");
 
-       //card.print_short();
-
        vector<OutputFlipHandler*> outputs;
 
        for (auto pipe : card.get_connected_pipelines())
@@ -193,14 +204,14 @@ int main()
 
 
                Plane* plane = 0;
-
+#if 0 // disable the plane for now
                for (Plane* p : crtc->get_possible_planes()) {
                        if (p->plane_type() == PlaneType::Overlay) {
                                plane = p;
                                break;
                        }
                }
-
+#endif
                OutputFlipHandler* output;
                if (plane)
                        output = new OutputFlipHandler(conn, crtc, mode, plane, 500, 400);