Rcpp Version 1.0.14
Loading...
Searching...
No Matches
Timertest.cpp
Go to the documentation of this file.
1// -*- mode: c++; compile-command: "g++ -Wall -O3 -o Timertest Timertest.cpp"; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2
3// from http://www.cs.uiowa.edu/~sriram/30/fall03/
4
5#include <iostream>
6#include <unistd.h>
7#include "Timer.h"
8
9int main() {
10 Timer test;
11
12 std::cout << "Sleeping 2 seconds" << std::endl;
13 test.Start();
14 sleep(2);
15 test.Stop();
16 std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl;
17 std::cout << "Sleeping 1 second" << std::endl;
18 test.Start();
19 sleep(1);
20 test.Stop();
21 std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl;
22 std::cout << "Cumulative time is " << test.CumulativeTime() << " seconds." << std::endl;
23 std::cout << "Reseting" << std::endl;
24 test.Reset();
25 std::cout << "Sleeping 2 seconds" << std::endl;
26 test.Start();
27 sleep(2);
28 test.Stop();
29 std::cout << "Sleep lasted for " << test.ElapsedTime() << " seconds." << std::endl;
30 std::cout << "Cumulative time is " << test.CumulativeTime() << " seconds." << std::endl;
31}
int main()
Definition Timertest.cpp:9
Definition Timer.h:31
double ElapsedTime()
Definition Timer.h:41
void Start()
Definition Timer.h:34
void Stop()
Definition Timer.h:35
double CumulativeTime()
Definition Timer.h:42
void Reset()
Definition Timer.h:40