Rcpp Version 1.0.9
SugarPerformance/Timertest.cpp

Simple test program for the C++ timer class

// -*- 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;
}
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