DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
timing.h
Go to the documentation of this file.
1
/*
2
Simple helper macros to time blocks or statements.
3
4
Copyright (C) 2007 Frank Richter
5
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License
8
as published by the Free Software Foundation; either version 2
9
of the License, or (at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15
See the GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21
*/
22
23
#ifndef __TIMING_H__
24
#define __TIMING_H__
25
26
#if defined(DO_TIMING)
27
28
#define TIMING_BEGIN double _timing_end_, _timing_start_ = Sys_DirtyTime();
29
#define TIMING_END_STR(S) \
30
_timing_end_ = Sys_DirtyTime(); \
31
Con_Printf ("%s: %.3g s\n", S, _timing_end_ - _timing_start_);
32
#define TIMING_END TIMING_END_STR(__FUNCTION__)
33
34
#define TIMING_INTERMEDIATE(S) \
35
{ \
36
double currentTime = Sys_DirtyTime(); \
37
Con_Printf ("%s: %.3g s\n", S, currentTime - _timing_start_); \
38
}
39
40
#define TIMING_TIMESTATEMENT(Stmt) \
41
{ \
42
TIMING_BEGIN \
43
Stmt; \
44
TIMING_END_STR(#Stmt); \
45
}
46
47
#else
48
49
#define TIMING_BEGIN
50
#define TIMING_END_STR(S)
51
#define TIMING_END
52
#define TIMING_INTERMEDIATE(S)
53
#define TIMING_TIMESTATEMENT(Stmt) Stmt
54
55
#endif
56
57
#endif
// __TIMING_H__
58
timing.h
Generated on Mon Mar 10 2025 16:50:17 for DarkPlaces by
1.12.0