Multi-Precision Arithmetic by C++ with no use of assembler
SN library Copyright (C) 1999-2018 K.Tsuru

Reference of class functions part 11


13. Timer class's member functions
The prototype declarations are given in "timer.h". It provides a method to measure the processing time. This class uses ANSI C/C++ functions only. Precision is about 1/CLOCKS_PER_SEC sec or 1.0 sec over 1000.0 seconds. Parallel measurements within ten timers are available.

Constructors
form
#include "timer.h"
Timer::Timer(int start = 0);
comment If the value "start" is zero (default) it stands by, else starts the measurement.

member functions
An object "timer" used below is declared as
#include "timer.h"
Timer timer;

Start
function "timer.Start();" resets the timer and starts the measurement.
form
#include "timer.h"
double Timer::Start();

LapTime
function "timer.LapTime()" returns lap time by a double value in seconds.
form
#include "timer.h"
double Timer::LapTime();

Stop
function "timer.Stop()" stops the timer and returns a passed time since start by a double value in seconds.
form
#include "timer.h"
double Timer::Stop();


Notice
On TurboLinux 4.0 the "LapTime()" function is reset i.e. returns a negative value after about 2,100 seconds since start using "clock()" function. Perhaps an overflow occurs. Then it uses "time()" function after 1000 seconds which provides an enough significant figures.