diff layer/RenderTimer.h @ 1221:eaab8bab3522

Measure time taken to render per pixel, and use the time last time around to decide whether to be time constrained this time around
author Chris Cannam
date Thu, 26 Jan 2017 11:55:11 +0000
parents 6f98aa5291d4
children a34a2a25907c
line wrap: on
line diff
--- a/layer/RenderTimer.h	Thu Jan 26 10:41:50 2017 +0000
+++ b/layer/RenderTimer.h	Thu Jan 26 11:55:11 2017 +0000
@@ -90,12 +90,22 @@
 	return false;
     }
 
+    double secondsPerItem(int itemsRendered) const {
+
+        if (itemsRendered == 0) return 0.0;
+
+	auto t = std::chrono::steady_clock::now();
+	double elapsed = std::chrono::duration<double>(t - m_start).count();
+
+        return elapsed / itemsRendered;
+    }
+
 private:
     std::chrono::time_point<std::chrono::steady_clock> m_start;
     bool m_haveLimits;
-    double m_minFraction;
-    double m_softLimit;
-    double m_hardLimit;
+    double m_minFraction; // proportion, 0.0 -> 1.0
+    double m_softLimit; // seconds
+    double m_hardLimit; // seconds
     bool m_softLimitOverridden;
 };