Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: third_party/qcms/src/tests/timing.h

Issue 2014023003: Add exact version of qcms used by Chrome for testing and comparison (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/qcms/src/tests/qcms_test_util.c ('k') | third_party/qcms/src/transform.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/qcms/src/tests/timing.h
diff --git a/third_party/qcms/src/tests/timing.h b/third_party/qcms/src/tests/timing.h
new file mode 100644
index 0000000000000000000000000000000000000000..83f1bbdf0cdfaa23d84b2bb0386fd39059ea46af
--- /dev/null
+++ b/third_party/qcms/src/tests/timing.h
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the Chromium LICENSE file.
+
+#ifndef TESTS_TIMING_H
+#define TESTS_TIMING_H
+
+#include <assert.h>
+#if defined(_WIN32)
+#include <windows.h>
+#else
+#include <sys/time.h>
+#endif
+#include <time.h>
+
+#if defined(_WIN32)
+
+static double seconds()
+{
+ static double clock_frequency;
+ static bool have_frequency;
+
+ LARGE_INTEGER qpc;
+ QueryPerformanceCounter(&qpc);
+ if (have_frequency)
+ return qpc.QuadPart * clock_frequency;
+
+ have_frequency = true;
+ QueryPerformanceFrequency(&qpc);
+ clock_frequency = 1.0 / (double) qpc.QuadPart;
+ return seconds();
+}
+
+#else
+
+static double seconds()
+{
+ struct timeval now;
+ gettimeofday(&now, 0);
+ return now.tv_sec + now.tv_usec * (1.0 / 1000000.0);
+}
+
+#endif
+
+#define TIME(function, time) do { \
+ double start = seconds(); \
+ (function); \
+ *time += seconds() - start; \
+} while (0)
+
+#endif // TESTS_TIMING_H
« no previous file with comments | « third_party/qcms/src/tests/qcms_test_util.c ('k') | third_party/qcms/src/transform.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698