Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/jxr/image/sys/perfTimer.h
4393 views
1
//*@@@+++@@@@******************************************************************
2
//
3
// Copyright © Microsoft Corp.
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 are met:
8
//
9
// • Redistributions of source code must retain the above copyright notice,
10
// this list of conditions and the following disclaimer.
11
// • Redistributions in binary form must reproduce the above copyright notice,
12
// this list of conditions and the following disclaimer in the documentation
13
// and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
// POSSIBILITY OF SUCH DAMAGE.
26
//
27
//*@@@---@@@@******************************************************************
28
29
#ifndef __PERFTIMER_H_
30
#define __PERFTIMER_H_
31
32
//***************************************************************************
33
// Description
34
//
35
// Performance timer API used to measure codec performance. The underlying
36
// implementation of this API may vary - from ANSI-C implementation via clock,
37
// Win32 implementation via QueryPerformanceCounter or GetProcessTimes. At
38
// present we only support one implementation of this PerfTimer "object".
39
// You choose the implementation by choosing which one of the many files
40
// to compile and link with your application.
41
//***************************************************************************
42
43
#ifdef DISABLE_PERF_MEASUREMENT
44
45
#define PERFTIMER_ONLY(code)
46
#define PERFTIMER_NEW(fPerf, ppPerfTimer)
47
#define PERFTIMER_DELETE(fPerf, ppPerfTimer)
48
#define PERFTIMER_START(fPerf, pPerfTimer)
49
#define PERFTIMER_STOP(fPerf, pPerfTimer)
50
#define PERFTIMER_GETRESULTS(fPerf, pPerfTimer, pResults)
51
#define PERFTIMER_COPYSTARTTIME(fPerf, pDst, pSrc)
52
#define PERFTIMER_REPORT(fPerf, pCodec)
53
54
#else // DISABLE_PERF_MEASUREMENT
55
56
#define PERFTIMER_ONLY(code) code
57
#define PERFTIMER_NEW(fPerf, ppPerfTimer) if (fPerf) {Bool b = b = PerfTimerNew(ppPerfTimer); assert(b);};
58
#define PERFTIMER_DELETE(fPerf, pPerfTimer) if (fPerf) {PerfTimerDelete(pPerfTimer);};
59
#define PERFTIMER_START(fPerf, pPerfTimer) if (fPerf) {Bool b = b = PerfTimerStart(pPerfTimer); assert(b);};
60
#define PERFTIMER_STOP(fPerf, pPerfTimer) if (fPerf) {Bool b = b = PerfTimerStop(pPerfTimer); assert(b);};
61
#define PERFTIMER_GETRESULTS(fPerf, pPerfTimer, pResults) \
62
if (fPerf) {Bool b = b = PerfTimerGetResults((pPerfTimer), (pResults)); assert(b);};
63
#define PERFTIMER_COPYSTARTTIME(fPerf, pDst, pSrc) \
64
if (fPerf) {Bool b = b = PerfTimerCopyStartTime((pDst), (pSrc)); assert(b);};
65
#define PERFTIMER_REPORT(fPerf, pCodec) \
66
if (fPerf) {OutputPerfTimerReport(pCodec);};
67
#endif // DISABLE_PERF_MEASUREMENT
68
69
//***************************************************************************
70
// Data Types
71
//***************************************************************************
72
typedef U64 PERFTIMERTIME;
73
typedef struct PERFTIMERRESULTS
74
{
75
PERFTIMERTIME iElapsedTime; // In nanoseconds or CPU cycles
76
PERFTIMERTIME iTicksPerSecond; // Number of ticks per second (clock frequency)
77
PERFTIMERTIME iZeroTimeIntervals; // Number of zero-time intervals.
78
// Presence of zero-time intervals may indicate insufficient clock precision
79
} PERFTIMERRESULTS;
80
81
#define NANOSECONDS_PER_SECOND 1000000000
82
83
84
//***************************************************************************
85
// Data Declarations
86
//***************************************************************************
87
typedef enum
88
{
89
CS_UNINIT,
90
CS_RUNNING,
91
CS_STOPPED,
92
} CLOCKSTATE;
93
94
typedef struct PERFTIMERSTATE
95
{
96
CLOCKSTATE eState;
97
PERFTIMERTIME iElapsedTime;
98
PERFTIMERTIME iPrevStartTime;
99
PERFTIMERTIME iZeroTimeIntervals;
100
} PERFTIMERSTATE;
101
102
103
//***************************************************************************
104
// Functions and Macros
105
//***************************************************************************
106
Bool PerfTimerNew(PERFTIMERSTATE **ppNewPerfTimer);
107
void PerfTimerDelete(PERFTIMERSTATE *pThisPerfTimer);
108
Bool PerfTimerStart(PERFTIMERSTATE *pThisPerfTimer);
109
Bool PerfTimerStop(PERFTIMERSTATE *pThisPerfTimer);
110
Bool PerfTimerGetResults(PERFTIMERSTATE *pThisPerfTimer,
111
PERFTIMERRESULTS *pPerfTimerResults);
112
Bool PerfTimerCopyStartTime(PERFTIMERSTATE *pDestPerfTimer,
113
PERFTIMERSTATE *pSrcPerfTimer);
114
115
#endif // __PERFTIMER_H_
116
117