-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprofiler.h
62 lines (51 loc) · 1.18 KB
/
profiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <string>
#include <stdint.h>
namespace profiler
{
enum Point
{
PROFILER_VIDEO_DRAW = 0,
PROFILER_AUDIO_WRITE,
PROFILER_DECODE_VIDEO_FRAME,
PROFILER_DECODE_AUDIO_FRAME,
PROFILER_PROCESS_VIDEO_FRAME,
PROFILER_PROCESS_AUDIO_FRAME,
PROFILER_NB
};
// simple flat profiler that keeps track
// of average time for a given profile point
struct Profiler
{
uint64_t startTime = 0;
uint64_t endTime = 0;
uint64_t currentTime = 0;
uint64_t totalTime = 0;
uint64_t count = 0;
uint64_t minTime = 0;
uint64_t maxTime = 0;
};
void Init();
void Enable(bool);
void GetPointName(Point, std::string&);
// Start a profiler block
void StartBlock(Point profiler);
void StopBlock(Point profiler);
// Print profiler point stats
void Print();
class ScopeProfiler
{
public:
ScopeProfiler(Point profiler)
: type(profiler)
{
StartBlock(type);
}
~ScopeProfiler()
{
StopBlock(type);
}
private:
Point type;
};
};