2 * Copyright (c) 2010 The WebM 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.
19 * Win32 specific includes
21 #ifndef WIN32_LEAN_AND_MEAN
22 #define WIN32_LEAN_AND_MEAN
27 * POSIX specific includes
31 /* timersub is not provided by msys at this time. */
33 #define timersub(a, b, result) \
35 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
36 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
37 if ((result)->tv_usec < 0) { \
39 (result)->tv_usec += 1000000; \
49 LARGE_INTEGER begin
, end
;
51 struct timeval begin
, end
;
57 vpx_usec_timer_start(struct vpx_usec_timer
*t
)
60 QueryPerformanceCounter(&t
->begin
);
62 gettimeofday(&t
->begin
, NULL
);
68 vpx_usec_timer_mark(struct vpx_usec_timer
*t
)
71 QueryPerformanceCounter(&t
->end
);
73 gettimeofday(&t
->end
, NULL
);
79 vpx_usec_timer_elapsed(struct vpx_usec_timer
*t
)
82 LARGE_INTEGER freq
, diff
;
84 diff
.QuadPart
= t
->end
.QuadPart
- t
->begin
.QuadPart
;
86 if (QueryPerformanceFrequency(&freq
) && diff
.QuadPart
< freq
.QuadPart
)
87 return (long)(diff
.QuadPart
* 1000000 / freq
.QuadPart
);
93 timersub(&t
->end
, &t
->begin
, &diff
);
94 return diff
.tv_sec
? 1000000 : diff
.tv_usec
;
98 #else /* CONFIG_OS_SUPPORT = 0*/
100 /* Empty timer functions if CONFIG_OS_SUPPORT = 0 */
102 #define timersub(a, b, result)
105 struct vpx_usec_timer
111 vpx_usec_timer_start(struct vpx_usec_timer
*t
) { }
114 vpx_usec_timer_mark(struct vpx_usec_timer
*t
) { }
117 vpx_usec_timer_elapsed(struct vpx_usec_timer
*t
) { return 0; }
119 #endif /* CONFIG_OS_SUPPORT */