[Spice-devel,v2,03/12] qxl-wddm-dod: Introduce TimeMeasurement class for timing debugging

Submitted by Yuri Benditovich on April 1, 2017, 4:40 p.m.

Details

Message ID 1491064839-13612-4-git-send-email-yuri.benditovich@daynix.com
State New
Headers show
Series "Set of patches for further support of VSync" ( rev: 2 ) in Spice

Not browsing as part of any series.

Commit Message

Yuri Benditovich April 1, 2017, 4:40 p.m.
From: "yuri.benditovich@daynix.com" <yuri.benditovich@daynix.com>

In release build this class resolved to empty statements.
In debug build it is useful for measurement of execution time.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
 qxldod/QxlDod.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Patch hide | download patch | download mbox

diff --git a/qxldod/QxlDod.h b/qxldod/QxlDod.h
index 45d5691..51c554d 100755
--- a/qxldod/QxlDod.h
+++ b/qxldod/QxlDod.h
@@ -225,6 +225,41 @@  typedef struct _CURRENT_BDD_MODE
     } FrameBuffer;
 } CURRENT_BDD_MODE;
 
+#if DBG
+class TimeMeasurement
+{
+public:
+    TimeMeasurement()
+    {
+        Start();
+    }
+    void Start()
+    {
+        KeQuerySystemTime(&li1);
+    }
+    void Stop()
+    {
+        KeQuerySystemTime(&li2);
+    }
+    ULONG Diff()
+    {
+        return (ULONG)((li2.QuadPart - li1.QuadPart) / 10000);
+    }
+protected:
+    LARGE_INTEGER li1;
+    LARGE_INTEGER li2;
+};
+#else
+class TimeMeasurement
+{
+public:
+    TimeMeasurement() {}
+    void Start() {}
+    void Stop() {}
+    ULONG Diff() { return 0; }
+};
+#endif
+
 class QxlDod;
 
 class HwDeviceInterface {