-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtesttictoc.cpp
72 lines (63 loc) · 1.52 KB
/
testtictoc.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* File: testtictoc.cpp
* Author: Marc
*
* Created on December 3, 2009, 2:31 PM
*/
#include <stdlib.h>
#include <iostream>
#include "tictoc.h"
#include "Timer.h"
#include "subpart.h"
using namespace TICTOC;
using namespace std;
/*
*
*/
void delayms (int nms);
void testTicToc();
int main(int argc, char** argv) {
testTicToc();
return (EXIT_SUCCESS);
}
void delayms (int nms) {
_TICTOC_TIC_FUNC
static Timer tim;
tim.start();
while (tim.getElapsedTimeInMilliSec() < nms) {
; //intentionally blank
}
tim.stop();
_TICTOC_TOC_FUNC
}
void testTicToc() {
tictoc bob;
bob.tic("timer tic");
// tictoc& timer = *(tictoc::timer);
timer().tic("all");
bob.toc("timer tic");
for (int j = 0; j < 10; ++j) {
bob.tic("timer tic");
timer().tic("outer loop");
bob.toc("timer tic");
delayOneClockIncrement();
for (int k = 0; k < 10; ++k) {
bob.tic("timer tic");
timer().tic ("inner loop");
bob.toc("timer tic");
delayms(1);
bob.tic("timer toc");
timer().toc ("inner loop");
bob.toc("timer toc");
}
bob.tic("timer toc");
timer().toc ("outer loop");
bob.toc("timer toc");
}
bob.tic("timer toc");
timer().toc("all");
bob.toc("timer toc");
cout << timer().generateReport();
cout << "\n" << bob.generateReport();
cout << "\naverage time for inner loop: " << timer().getStatistics("inner loop") << "\n";
}