2 Simple helper macros to time blocks or statements.
4 Copyright (C) 2007 Frank Richter
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.
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.
15 See the GNU General Public License for more details.
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.
26 #if defined(DO_TIMING)
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__)
34 #define TIMING_INTERMEDIATE(S) \
36 double currentTime = Sys_DirtyTime(); \
37 Con_Printf ("%s: %.3g s\n", S, currentTime - _timing_start_); \
40 #define TIMING_TIMESTATEMENT(Stmt) \
44 TIMING_END_STR(#Stmt); \
50 #define TIMING_END_STR(S)
52 #define TIMING_INTERMEDIATE(S)
53 #define TIMING_TIMESTATEMENT(Stmt) Stmt
57 #endif // __TIMING_H__