Add ICU message format support
[chromium-blink-merge.git] / third_party / qcms / src / tests / timing.h
blob83f1bbdf0cdfaa23d84b2bb0386fd39059ea46af
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.
5 #ifndef TESTS_TIMING_H
6 #define TESTS_TIMING_H
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>
16 #if defined(_WIN32)
18 static double seconds()
20 static double clock_frequency;
21 static bool have_frequency;
23 LARGE_INTEGER qpc;
24 QueryPerformanceCounter(&qpc);
25 if (have_frequency)
26 return qpc.QuadPart * clock_frequency;
28 have_frequency = true;
29 QueryPerformanceFrequency(&qpc);
30 clock_frequency = 1.0 / (double) qpc.QuadPart;
31 return seconds();
34 #else
36 static double seconds()
38 struct timeval now;
39 gettimeofday(&now, 0);
40 return now.tv_sec + now.tv_usec * (1.0 / 1000000.0);
43 #endif
45 #define TIME(function, time) do { \
46 double start = seconds(); \
47 (function); \
48 *time += seconds() - start; \
49 } while (0)
51 #endif // TESTS_TIMING_H