-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebug.cpp
58 lines (46 loc) · 1.08 KB
/
Debug.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* @file Debug.h
* @author Dan R. Lipsa
*
* Stream for printing debug messages. All debug messages have to go
* to cdbg. It works with both MS Visual C++ and with GCC
*/
#include "Debug.h"
#ifdef _MSC_VER
DebugStream cdbg;
#else //_MSC_VER
ostream& cdbg = cerr;
#endif //_MSC_VER
MeasureTime::MeasureTime ()
{
StartInterval ();
}
void MeasureTime::StartInterval ()
{
m_start = clock ();
}
void MeasureTime::EndInterval (const char* intervalName)
{
clock_t end = clock ();
cdbg << intervalName << ": "
<< (end - m_start) * 1000.0 / CLOCKS_PER_SEC << " ms" << endl;
m_start = end;
}
void MeasureTimeVtk::Execute (
vtkObject *caller, unsigned long eventId, void *callData)
{
(void)callData;
if (eventId == vtkCommand::StartEvent)
{
m_measure.StartInterval ();
}
else if (eventId == vtkCommand::EndEvent)
{
m_measure.EndInterval (caller->GetClassName ());
}
}
void MeasureTimeVtk::Measure (vtkObject* caller)
{
caller->AddObserver (vtkCommand::StartEvent, this);
caller->AddObserver (vtkCommand::EndEvent, this);
}