-
-
Notifications
You must be signed in to change notification settings - Fork 220
Expand file tree
/
Copy pathTimertest.cpp
More file actions
31 lines (27 loc) · 1.07 KB
/
Timertest.cpp
File metadata and controls
31 lines (27 loc) · 1.07 KB
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
// -*- mode: c++; compile-command: "g++ -Wall -O3 -o Timertest Timertest.cpp"; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
// from http://www.cs.uiowa.edu/~sriram/30/fall03/
#include <iostream>
#include <unistd.h>
#include "Timer.h"
int main() {
Timer test;
std::cout << "Sleeping 2 seconds" << std::endl;
test.Start();
sleep(2);
test.Stop();
std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl;
std::cout << "Sleeping 1 second" << std::endl;
test.Start();
sleep(1);
test.Stop();
std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl;
std::cout << "Cumulative time is " << test.CumulativeTime() << " seconds." << std::endl;
std::cout << "Reseting" << std::endl;
test.Reset();
std::cout << "Sleeping 2 seconds" << std::endl;
test.Start();
sleep(2);
test.Stop();
std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl;
std::cout << "Cumulative time is " << test.CumulativeTime() << " seconds." << std::endl;
}