-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtimer.cpp
26 lines (20 loc) · 816 Bytes
/
timer.cpp
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
/* Timing services (threadsafe).
AUTHOR: Dmitry I. Lyakh (Liakh): [email protected]
REVISION: 2020/07/21
Copyright (C) 2014-2022 Dmitry I. Lyakh (Liakh)
Copyright (C) 2014-2022 Oak Ridge National Laboratory (UT-Battelle)
LICENSE: BSD 3-Clause */
#include "timer.h"
#include <chrono>
double time_sys_sec()
{
auto stamp = std::chrono::system_clock::now(); //current time point
auto durat = std::chrono::duration<double>(stamp.time_since_epoch()); //duration (sec) since the begining of the clock
return durat.count(); //number of seconds
}
double time_high_sec()
{
auto stamp = std::chrono::high_resolution_clock::now(); //current time point
auto durat = std::chrono::duration<double>(stamp.time_since_epoch()); //duration (sec) since the begining of the clock
return durat.count(); //number of seconds
}