VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
System
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 "vtkCommonSystemModule.h"
// For export macro
37
#include "
vtkObject.h
"
38
39
#ifdef _WIN32
40
#include <sys/types.h>
// Needed for Win32 implementation of timer
41
#include <sys/timeb.h>
// Needed for Win32 implementation of timer
42
#else
43
#include <time.h>
// Needed for unix implementation of timer
44
#include <sys/time.h>
// Needed for unix implementation of timer
45
#include <sys/types.h>
// Needed for unix implementation of timer
46
#include <sys/times.h>
// Needed for unix implementation of timer
47
#endif
48
49
// var args
50
#ifndef _WIN32
51
#include <unistd.h>
// Needed for unix implementation of timer
52
#endif
53
54
// select stuff here is for sleep method
55
#ifndef NO_FD_SET
56
# define SELECT_MASK fd_set
57
#else
58
# ifndef _AIX
59
typedef
long
fd_mask;
60
# endif
61
# if defined(_IBMR2)
62
# define SELECT_MASK void
63
# else
64
# define SELECT_MASK int
65
# endif
66
#endif
67
68
69
#define VTK_LOG_EVENT_LENGTH 40
70
71
//BTX
72
typedef
struct
73
{
74
double
WallTime
;
75
int
CpuTicks
;
76
char
Event[
VTK_LOG_EVENT_LENGTH
];
77
unsigned
char
Indent
;
78
}
vtkTimerLogEntry
;
79
//ETX
80
81
class
VTKCOMMONSYSTEM_EXPORT
vtkTimerLog
:
public
vtkObject
82
{
83
public
:
84
static
vtkTimerLog
*
New
();
85
86
vtkTypeMacro(
vtkTimerLog
,
vtkObject
);
87
void
PrintSelf
(ostream& os,
vtkIndent
indent);
88
90
92
static
void
SetLogging
(
int
v) {
vtkTimerLog::Logging
= v;}
93
static
int
GetLogging
() {
return
vtkTimerLog::Logging
;}
94
static
void
LoggingOn
() {
vtkTimerLog::SetLogging
(1);}
95
static
void
LoggingOff
() {
vtkTimerLog::SetLogging
(0);}
97
99
100
static
void
SetMaxEntries(
int
a);
101
static
int
GetMaxEntries();
103
104
//BTX
106
108
static
void
FormatAndMarkEvent(
const
char
*EventString, ...);
109
//ETX
111
114
static
void
DumpLog(
const
char
*filename);
115
117
120
static
void
MarkStartEvent(
const
char
*EventString);
121
static
void
MarkEndEvent(
const
char
*EventString);
122
//BTX
123
static
void
DumpLogWithIndents(ostream *os,
double
threshold);
124
//ETX
126
128
129
static
int
GetNumberOfEvents();
130
static
int
GetEventIndent(
int
i);
131
static
double
GetEventWallTime(
int
i);
132
static
const
char
* GetEventString(
int
i);
134
136
static
void
MarkEvent(
const
char
*EventString);
137
140
static
void
ResetLog();
141
143
static
void
AllocateLog();
144
146
static
void
CleanupLog();
147
150
static
double
GetUniversalTime();
151
154
static
double
GetCPUTime();
155
157
void
StartTimer();
158
160
void
StopTimer();
161
164
double
GetElapsedTime();
165
166
protected
:
167
vtkTimerLog
() {this->StartTime=0; this->EndTime = 0;};
//insure constructor/destructor protected
168
virtual
~vtkTimerLog
() { };
169
170
static
vtkTimerLogEntry
* GetEvent(
int
i);
171
172
static
int
Logging
;
173
static
int
Indent
;
174
static
int
MaxEntries
;
175
static
int
NextEntry
;
176
static
int
WrapFlag
;
177
static
int
TicksPerSecond
;
178
static
vtkTimerLogEntry
*
TimerLog
;
179
180
#ifdef _WIN32
181
#ifndef _WIN32_WCE
182
static
timeb FirstWallTime;
183
static
timeb CurrentWallTime;
184
#else
185
static
FILETIME FirstWallTime;
186
static
FILETIME CurrentWallTime;
187
#endif
188
#else
189
static
timeval
FirstWallTime
;
190
static
timeval
CurrentWallTime
;
191
static
tms
FirstCpuTicks
;
192
static
tms
CurrentCpuTicks
;
193
#endif
194
195
// instance variables to support simple timing functionality,
196
// separate from timer table logging.
197
double
StartTime
;
198
double
EndTime
;
199
200
//BTX
201
static
void
DumpEntry(ostream& os,
int
index
,
double
time
,
double
deltatime,
202
int
tick,
int
deltatick,
const
char
*event);
203
//ETX
204
205
private
:
206
vtkTimerLog
(
const
vtkTimerLog
&);
// Not implemented.
207
void
operator=(
const
vtkTimerLog
&);
// Not implemented.
208
};
209
210
211
//
212
// Set built-in type. Creates member Set"name"() (e.g., SetVisibility());
213
//
214
#define vtkTimerLogMacro(string) \
215
{ \
216
vtkTimerLog::FormatAndMarkEvent("Mark: In %s, line %d, class %s: %s", \
217
__FILE__, __LINE__, this->GetClassName(), string); \
218
}
219
220
#endif
Generated on Thu May 24 2012 22:22:13 for VTK by
1.8.1