2 * Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
17 * Win32 specific includes
19 #ifndef WIN32_LEAN_AND_MEAN
20 #define WIN32_LEAN_AND_MEAN
25 * POSIX specific includes
29 /* timersub is not provided by msys at this time. */
31 #define timersub(a, b, result) \
33 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
34 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
35 if ((result)->tv_usec < 0) { \
37 (result)->tv_usec += 1000000; \
47 LARGE_INTEGER begin
, end
;
49 struct timeval begin
, end
;
55 vpx_usec_timer_start(struct vpx_usec_timer
*t
)
58 QueryPerformanceCounter(&t
->begin
);
60 gettimeofday(&t
->begin
, NULL
);
66 vpx_usec_timer_mark(struct vpx_usec_timer
*t
)
69 QueryPerformanceCounter(&t
->end
);
71 gettimeofday(&t
->end
, NULL
);
77 vpx_usec_timer_elapsed(struct vpx_usec_timer
*t
)
80 LARGE_INTEGER freq
, diff
;
82 diff
.QuadPart
= t
->end
.QuadPart
- t
->begin
.QuadPart
;
84 if (QueryPerformanceFrequency(&freq
) && diff
.QuadPart
< freq
.QuadPart
)
85 return (long)(diff
.QuadPart
* 1000000 / freq
.QuadPart
);
91 timersub(&t
->end
, &t
->begin
, &diff
);
92 return diff
.tv_sec
? 1000000 : diff
.tv_usec
;