VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
vtkTimerLog.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkTimerLog.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
33
#ifndef __vtkTimerLog_h
34
#define __vtkTimerLog_h
35
36
#include "
vtkObject.h
"
37
38
#ifdef _WIN32
39
#ifndef _WIN32_WCE
40
#include <sys/types.h>
// Needed for Win32 implementation of timer
41
#include <sys/timeb.h>
// Needed for Win32 implementation of timer
42
#endif
43
#else
44
#include <time.h>
// Needed for unix implementation of timer
45
#include <sys/time.h>
// Needed for unix implementation of timer
46
#include <sys/types.h>
// Needed for unix implementation of timer
47
#include <sys/times.h>
// Needed for unix implementation of timer
48
#endif
49
50
// var args
51
#ifndef _WIN32
52
#include <unistd.h>
// Needed for unix implementation of timer
53
#endif
54
55
// select stuff here is for sleep method
56
#ifndef NO_FD_SET
57
# define SELECT_MASK fd_set
58
#else
59
# ifndef _AIX
60
typedef
long
fd_mask;
61
# endif
62
# if defined(_IBMR2)
63
# define SELECT_MASK void
64
# else
65
# define SELECT_MASK int
66
# endif
67
#endif
68
69
70
#define VTK_LOG_EVENT_LENGTH 40
71
72
//BTX
73
typedef
struct
74
{
75
double
WallTime
;
76
int
CpuTicks
;
77
char
Event[
VTK_LOG_EVENT_LENGTH
];
78
unsigned
char
Indent
;
79
}
vtkTimerLogEntry
;
80
//ETX
81
82
class
VTK_COMMON_EXPORT
vtkTimerLog
:
public
vtkObject
83
{
84
public
:
85
static
vtkTimerLog
*
New
();
86
87
vtkTypeMacro(
vtkTimerLog
,
vtkObject
);
88
void
PrintSelf
(ostream& os,
vtkIndent
indent);
89
91
93
static
void
SetLogging
(
int
v) {
vtkTimerLog::Logging
= v;}
94
static
int
GetLogging
() {
return
vtkTimerLog::Logging
;}
95
static
void
LoggingOn
() {
vtkTimerLog::SetLogging
(1);}
96
static
void
LoggingOff
() {
vtkTimerLog::SetLogging
(0);}
98
100
101
static
void
SetMaxEntries(
int
a);
102
static
int
GetMaxEntries();
104
105
//BTX
107
109
static
void
FormatAndMarkEvent(
const
char
*EventString, ...);
110
//ETX
112
115
static
void
DumpLog(
const
char
*filename);
116
118
121
static
void
MarkStartEvent(
const
char
*EventString);
122
static
void
MarkEndEvent(
const
char
*EventString);
123
//BTX
124
static
void
DumpLogWithIndents(ostream *os,
double
threshold);
125
//ETX
127
129
130
static
int
GetNumberOfEvents();
131
static
int
GetEventIndent(
int
i);
132
static
double
GetEventWallTime(
int
i);
133
static
const
char
* GetEventString(
int
i);
135
137
static
void
MarkEvent(
const
char
*EventString);
138
141
static
void
ResetLog();
142
144
static
void
AllocateLog();
145
147
static
void
CleanupLog();
148
151
static
double
GetUniversalTime();
152
155
static
double
GetCPUTime();
156
158
void
StartTimer();
159
161
void
StopTimer();
162
165
double
GetElapsedTime();
166
167
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
168
# define GetTickCount GetCurrentTime
169
#endif
170
173
VTK_LEGACY(
static
double
GetCurrentTime());
174
175
#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
176
# undef GetTickCount
177
//BTX
178
VTK_LEGACY(
static
double
GetTickCount());
179
//ETX
180
#endif
181
182
protected
:
183
vtkTimerLog
() {this->StartTime=0; this->EndTime = 0;};
//insure constructor/destructor protected
184
virtual
~vtkTimerLog
() { };
185
186
static
vtkTimerLogEntry
* GetEvent(
int
i);
187
188
static
int
Logging
;
189
static
int
Indent
;
190
static
int
MaxEntries
;
191
static
int
NextEntry
;
192
static
int
WrapFlag
;
193
static
int
TicksPerSecond
;
194
static
vtkTimerLogEntry
*
TimerLog
;
195
196
#ifdef _WIN32
197
#ifndef _WIN32_WCE
198
static
timeb FirstWallTime;
199
static
timeb CurrentWallTime;
200
#else
201
static
FILETIME FirstWallTime;
202
static
FILETIME CurrentWallTime;
203
#endif
204
#else
205
static
timeval
FirstWallTime
;
206
static
timeval
CurrentWallTime
;
207
static
tms
FirstCpuTicks
;
208
static
tms
CurrentCpuTicks
;
209
#endif
210
211
// instance variables to support simple timing functionality,
212
// separate from timer table logging.
213
double
StartTime
;
214
double
EndTime
;
215
216
//BTX
217
static
void
DumpEntry(ostream& os,
int
index,
double
time,
double
deltatime,
218
int
tick,
int
deltatick,
const
char
*event);
219
//ETX
220
221
private
:
222
vtkTimerLog
(
const
vtkTimerLog
&);
// Not implemented.
223
void
operator=(
const
vtkTimerLog
&);
// Not implemented.
224
};
225
226
227
//
228
// Set built-in type. Creates member Set"name"() (e.g., SetVisibility());
229
//
230
#define vtkTimerLogMacro(string) \
231
{ \
232
vtkTimerLog::FormatAndMarkEvent("Mark: In %s, line %d, class %s: %s", \
233
__FILE__, __LINE__, this->GetClassName(), string); \
234
}
235
236
#endif
Generated on Sun Sep 15 2013 03:44:20 for VTK by
1.8.4