File: Timertest.cpp

package info (click to toggle)
rcpp 1.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,480 kB
  • sloc: cpp: 27,436; ansic: 7,778; sh: 53; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 1,091 bytes parent folder | download | duplicates (9)
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;
}