summaryrefslogtreecommitdiff
path: root/src/ToolBox/superpmi/superpmi-shared/simpletimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ToolBox/superpmi/superpmi-shared/simpletimer.cpp')
-rw-r--r--src/ToolBox/superpmi/superpmi-shared/simpletimer.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/ToolBox/superpmi/superpmi-shared/simpletimer.cpp b/src/ToolBox/superpmi/superpmi-shared/simpletimer.cpp
new file mode 100644
index 0000000000..e9c76339bc
--- /dev/null
+++ b/src/ToolBox/superpmi/superpmi-shared/simpletimer.cpp
@@ -0,0 +1,56 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+#include "standardpch.h"
+#include "logging.h"
+#include "simpletimer.h"
+
+SimpleTimer::SimpleTimer()
+{
+ start.QuadPart = 0;
+ stop.QuadPart = 0;
+
+ BOOL retVal = ::QueryPerformanceFrequency(&proc_freq);
+ if(retVal == FALSE)
+ {
+ LogDebug("SimpleTimer::SimpleTimer unable to QPF. error was 0x%08x", ::GetLastError());
+ ::__debugbreak();
+ }
+}
+
+SimpleTimer::~SimpleTimer()
+{
+}
+
+void SimpleTimer::Start()
+{
+ BOOL retVal = ::QueryPerformanceCounter(&start);
+ if(retVal == FALSE)
+ {
+ LogDebug("SimpleTimer::Start unable to QPC. error was 0x%08x", ::GetLastError());
+ ::__debugbreak();
+ }
+}
+
+void SimpleTimer::Stop()
+{
+ BOOL retVal = ::QueryPerformanceCounter(&stop);
+ if(retVal == FALSE)
+ {
+ LogDebug("SimpleTimer::Stop unable to QPC. error was 0x%08x", ::GetLastError());
+ ::__debugbreak();
+ }
+}
+
+double SimpleTimer::GetMilliseconds()
+{
+ return GetSeconds()*1000.0;
+}
+
+double SimpleTimer::GetSeconds()
+{
+ return ((stop.QuadPart - start.QuadPart) / (double)proc_freq.QuadPart);
+}
+