/src/openh264/codec/common/inc/measure_time.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*! |
2 | | * \copy |
3 | | * Copyright (c) 2009-2013, Cisco Systems |
4 | | * All rights reserved. |
5 | | * |
6 | | * Redistribution and use in source and binary forms, with or without |
7 | | * modification, are permitted provided that the following conditions |
8 | | * are met: |
9 | | * |
10 | | * * Redistributions of source code must retain the above copyright |
11 | | * notice, this list of conditions and the following disclaimer. |
12 | | * |
13 | | * * Redistributions in binary form must reproduce the above copyright |
14 | | * notice, this list of conditions and the following disclaimer in |
15 | | * the documentation and/or other materials provided with the |
16 | | * distribution. |
17 | | * |
18 | | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
21 | | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
22 | | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
23 | | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
24 | | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 | | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
26 | | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
27 | | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
28 | | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | | * POSSIBILITY OF SUCH DAMAGE. |
30 | | * |
31 | | * |
32 | | * \file measure_time.h |
33 | | * |
34 | | * \brief time cost measure utilization |
35 | | * |
36 | | * \date 04/28/2009 Created |
37 | | * |
38 | | ************************************************************************************* |
39 | | */ |
40 | | #ifndef WELS_TIME_COST_MEASURE_UTIL_H__ |
41 | | #define WELS_TIME_COST_MEASURE_UTIL_H__ |
42 | | |
43 | | #include <stdlib.h> |
44 | | |
45 | | #include "typedefs.h" |
46 | | #ifndef _WIN32 |
47 | | #include <sys/time.h> |
48 | | #else |
49 | | #include <windows.h> |
50 | | #endif |
51 | | #include <time.h> |
52 | | |
53 | | #ifdef __cplusplus |
54 | | extern "C" { |
55 | | #endif//__cplusplus |
56 | | |
57 | | /*! |
58 | | * \brief time cost measure utilization |
59 | | * \param void |
60 | | * \return time elapsed since run (unit: microsecond) |
61 | | */ |
62 | | |
63 | 0 | static inline int64_t WelsTime (void) { |
64 | 0 | #ifndef _WIN32 |
65 | 0 | struct timeval tv_date; |
66 | |
|
67 | 0 | gettimeofday (&tv_date, NULL); |
68 | 0 | return ((int64_t) tv_date.tv_sec * 1000000 + (int64_t) tv_date.tv_usec); |
69 | | #else |
70 | | static int64_t iMtimeFreq = 0; |
71 | | int64_t iMtimeCur = 0; |
72 | | int64_t iResult = 0; |
73 | | if (!iMtimeFreq) { |
74 | | QueryPerformanceFrequency ((LARGE_INTEGER*)&iMtimeFreq); |
75 | | if (!iMtimeFreq) |
76 | | iMtimeFreq = 1; |
77 | | } |
78 | | QueryPerformanceCounter ((LARGE_INTEGER*)&iMtimeCur); |
79 | | iResult = (int64_t) ((double)iMtimeCur * 1e6 / (double)iMtimeFreq + 0.5); |
80 | | return iResult; |
81 | | #endif//_WIN32 |
82 | 0 | } Unexecuted instantiation: welsEncoderExt.cpp:WelsTime() Unexecuted instantiation: welsDecoderExt.cpp:WelsTime() Unexecuted instantiation: encoder_ext.cpp:WelsTime() Unexecuted instantiation: slice_multi_threading.cpp:WelsTime() Unexecuted instantiation: wels_task_encoder.cpp:WelsTime() |
83 | | |
84 | | #ifdef __cplusplus |
85 | | } |
86 | | #endif |
87 | | |
88 | | #endif//WELS_TIME_COST_MEASURE_UTIL_H__ |