Cheetah Software
1.0
Main Page
Namespaces
Classes
Files
File List
File Members
Timer.h
Go to the documentation of this file.
1
5
#ifndef PROJECT_TIMER_H
6
#define PROJECT_TIMER_H
7
8
#include <assert.h>
9
#include <stdint.h>
10
#include <time.h>
11
12
class
Timer
{
13
public
:
14
explicit
Timer
() {
start
(); }
15
16
void
start
() { clock_gettime(CLOCK_MONOTONIC, &
_startTime
); }
17
18
double
getMs
() {
return
(
double
)
getNs
() / 1.e6; }
19
20
int64_t
getNs
() {
21
struct
timespec now;
22
clock_gettime(CLOCK_MONOTONIC, &now);
23
return
(int64_t)(now.tv_nsec -
_startTime
.tv_nsec) +
24
1000000000 * (now.tv_sec -
_startTime
.tv_sec);
25
}
26
27
double
getSeconds
() {
return
(
double
)
getNs
() / 1.e9; }
28
29
struct
timespec
_startTime
;
30
};
31
32
#endif // PROJECT_TIMER_H
Timer::Timer
Timer()
Definition:
Timer.h:14
Timer
Definition:
Timer.h:12
Timer::getNs
int64_t getNs()
Definition:
Timer.h:20
Timer::start
void start()
Definition:
Timer.h:16
Timer::getSeconds
double getSeconds()
Definition:
Timer.h:27
Timer::_startTime
struct timespec _startTime
Definition:
Timer.h:29
Timer::getMs
double getMs()
Definition:
Timer.h:18
home
dhkim
Public_Repository
Cheetah-Software
common
include
Utilities
Timer.h
Generated by
1.8.11