summaryrefslogtreecommitdiff
path: root/debug_tools/WatchYourStep/ptxjitplus/inc/timer.h
diff options
context:
space:
mode:
authorJonathan <[email protected]>2018-06-26 13:20:39 -0700
committerJonathan <[email protected]>2018-06-26 13:20:39 -0700
commit584ebaa74a838680e6ed1fa13ac266e88c30c071 (patch)
tree59523a4db9b6b4923611777928818d0bfc8b0ffc /debug_tools/WatchYourStep/ptxjitplus/inc/timer.h
parent978730086509050df16b77b9fbb4cc3ef19f3f6a (diff)
exports and imports param data in new debug tool: WatchYourStep
Diffstat (limited to 'debug_tools/WatchYourStep/ptxjitplus/inc/timer.h')
-rw-r--r--debug_tools/WatchYourStep/ptxjitplus/inc/timer.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/debug_tools/WatchYourStep/ptxjitplus/inc/timer.h b/debug_tools/WatchYourStep/ptxjitplus/inc/timer.h
new file mode 100644
index 0000000..d856eb1
--- /dev/null
+++ b/debug_tools/WatchYourStep/ptxjitplus/inc/timer.h
@@ -0,0 +1,64 @@
+/**
+ * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
+ *
+ * Please refer to the NVIDIA end user license agreement (EULA) associated
+ * with this source code for terms and conditions that govern your use of
+ * this software. Any use, reproduction, disclosure, or distribution of
+ * this software and related documentation outside the terms of the EULA
+ * is strictly prohibited.
+ *
+ */
+
+#ifndef TIMER_H
+#define TIMER_H
+
+#include <stdlib.h>
+
+#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+
+#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+double PCFreq = 0.0;
+__int64 timerStart = 0;
+#else
+struct timeval timerStart;
+#endif
+
+void StartTimer()
+{
+#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+ LARGE_INTEGER li;
+
+ if (!QueryPerformanceFrequency(&li))
+ {
+ printf("QueryPerformanceFrequency failed!\n");
+ }
+
+ PCFreq = (double)li.QuadPart/1000.0;
+ QueryPerformanceCounter(&li);
+ timerStart = li.QuadPart;
+#else
+ gettimeofday(&timerStart, NULL);
+#endif
+}
+
+// time elapsed in ms
+double GetTimer()
+{
+#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
+ LARGE_INTEGER li;
+ QueryPerformanceCounter(&li);
+ return (double)(li.QuadPart-timerStart)/PCFreq;
+#else
+ struct timeval timerStop, timerElapsed;
+ gettimeofday(&timerStop, NULL);
+ timersub(&timerStop, &timerStart, &timerElapsed);
+ return timerElapsed.tv_sec*1000.0+timerElapsed.tv_usec/1000.0;
+#endif
+}
+#endif // TIMER_H
+