DGtal
0.6.devel
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
tests
base
testClock.cpp
1
34
#include <cstdio>
35
#include <cmath>
36
#include <iostream>
37
#include "DGtal/base/Common.h"
38
#include "DGtal/base/Clock.h"
39
40
using namespace
DGtal;
41
using namespace
std;
42
44
bool
test_minimalTick()
45
{
46
double
tick;
47
Clock
c;
48
49
trace
.
info
() << c <<std::endl;
50
51
c.
startClock
();
52
tick = c.
stopClock
();
53
trace
.
info
() <<
"Minimal tick: "
<< tick <<endl;
54
return
(tick >= 0);
55
}
56
58
bool
test_loopTick()
59
{
60
double
tick,tmp=0;
61
62
Clock
c;
63
c.
startClock
();
64
for
(
unsigned
int
i=0 ; i< 4334450; i++)
65
tmp = cos(tmp+i);
66
67
tick = c.
stopClock
();
68
trace
.
info
()<<
"Loop tick: "
<< tick <<endl;
69
return
(tick >= 0);
70
}
71
73
bool
test_MultipleLoop()
74
{
75
double
tick1,tick2,tick3,tmp=0;
76
77
Clock
c,c2,c3;
78
79
c3.
startClock
();
80
c.
startClock
();
81
for
(
unsigned
int
i=0 ; i< 4334450; i++)
82
tmp = cos(tmp+i);
83
84
c2.
startClock
();
85
for
(
unsigned
int
i=0 ; i< 4334450; i++)
86
tmp = cos(tmp+i);
87
88
tick2 = c2.
stopClock
();
89
90
for
(
unsigned
int
i=0 ; i< 4334450; i++)
91
tmp = cos(tmp+i);
92
93
tick1 = c.
stopClock
();
94
tick3=c3.
stopClock
();
95
96
trace
.
info
()<<
"Loop tick1: "
<< tick1
97
<<
" Loop tick2: "
<< tick2
98
<<
" total: "
<< tick3 <<endl;
99
return
((tick3 >= tick1) && (tick1 >= 0));
100
}
101
102
103
int
main()
104
{
105
if
(test_minimalTick() && test_loopTick() && test_MultipleLoop())
106
return
0;
107
else
108
return
1;
109
110
}
Generated on Wed Dec 19 2012 19:10:37 for DGtal by
1.8.1.1