forked from packetflinger/q2admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.h
More file actions
44 lines (39 loc) · 1.73 KB
/
profile.h
File metadata and controls
44 lines (39 loc) · 1.73 KB
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
/**
* Q2Admin
* Profiling macros, only really used for development
*/
#pragma once
#define profile_init(instance) unsigned long performancetimer##instance = 0;
#define profile_init_2(instance) \
unsigned long performancetimer##instance = 0; \
static unsigned long totalperformancetimer##instance = 0; \
static int countperformancetimer##instance = 0
#define profile_start(instance) \
if(isLogEvent(LT_PERFORMANCEMONITOR)) \
{ \
performancetimer##instance = clock(); \
}
#define profile_stop(instance, function, client, ent) \
if(isLogEvent(LT_PERFORMANCEMONITOR)) \
{ \
performancetimer##instance = clock() - performancetimer##instance; \
if(performancetimer##instance) \
{ \
logEvent(LT_PERFORMANCEMONITOR, client, ent, function, 0, (double)performancetimer##instance / CLOCKS_PER_SEC); \
} \
}
#define profile_stop_2(instance, function, client, ent) \
if(isLogEvent(LT_PERFORMANCEMONITOR)) \
{ \
totalperformancetimer##instance += clock() - performancetimer##instance; \
countperformancetimer##instance++; \
if(countperformancetimer##instance >= 100) \
{ \
if(totalperformancetimer##instance) \
{ \
logEvent(LT_PERFORMANCEMONITOR, client, ent, function, 0, (double)totalperformancetimer##instance / (100.0 * CLOCKS_PER_SEC)); \
} \
totalperformancetimer##instance = 0; \
countperformancetimer##instance = 0; \
} \
}