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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the Chromium LICENSE file.
4
5 #ifndef TESTS_TIMING_H
6 #define TESTS_TIMING_H
7
8 #include <assert.h>
9 #if defined(_WIN32)
10 #include <windows.h>
11 #else
12 #include <sys/time.h>
13 #endif
14 #include <time.h>
15
16 #if defined(_WIN32)
17
18 static double seconds()
19 {
20 static double clock_frequency;
21 static bool have_frequency;
22
23 LARGE_INTEGER qpc;
24 QueryPerformanceCounter(&qpc);
25 if (have_frequency)
26 return qpc.QuadPart * clock_frequency;
27
28 have_frequency = true;
29 QueryPerformanceFrequency(&qpc);
30 clock_frequency = 1.0 / (double) qpc.QuadPart;
31 return seconds();
32 }
33
34 #else
35
36 static double seconds()
37 {
38 struct timeval now;
39 gettimeofday(&now, 0);
40 return now.tv_sec + now.tv_usec * (1.0 / 1000000.0);
41 }
42
43 #endif
44
45 #define TIME(function, time) do { \
46 double start = seconds(); \
47 (function); \
48 *time += seconds() - start; \
49 } while (0)
50
51 #endif // TESTS_TIMING_H
OLDNEW
« 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