aboutsummaryrefslogtreecommitdiff
path: root/Src/replicant/nu/Benchmark.h
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/replicant/nu/Benchmark.h
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/replicant/nu/Benchmark.h')
-rw-r--r--Src/replicant/nu/Benchmark.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/Src/replicant/nu/Benchmark.h b/Src/replicant/nu/Benchmark.h
new file mode 100644
index 00000000..3fcd3b0b
--- /dev/null
+++ b/Src/replicant/nu/Benchmark.h
@@ -0,0 +1,44 @@
+#ifndef BENCHMARKH
+#define BENCHMARKH
+
+
+#if defined(_WIN32)
+static uint64_t Benchmark()
+{
+ return GetTickCount64();
+}
+
+#elif defined(__ANDROID__)
+#include <time.h>
+
+// Make sure to divide by 1000000 (1 million) to get results in Milliseconds, as they are returned in nanoseconds
+static uint64_t Benchmark()
+{
+ struct timespec ts;
+ uint64_t count;
+ clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
+ count=(uint64_t)ts.tv_sec*1000000000ULL + (uint64_t)ts.tv_nsec;
+ return count;
+}
+
+#elif defined(__APPLE__)
+#include <mach/mach_time.h>
+static uint64_t Benchmark()
+{
+ uint64_t absoluteTime;
+ static mach_timebase_info_data_t timeBase = {0,0};
+
+ absoluteTime = mach_absolute_time();
+
+ if (0 == timeBase.denom)
+ {
+ kern_return_t err = mach_timebase_info(&timeBase);
+ if (0 != err)
+ return 0;
+ }
+ uint64_t nanoTime = absoluteTime * timeBase.numer / timeBase.denom;
+ return nanoTime/(1000*1000);
+}
+#endif
+
+#endif \ No newline at end of file