-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.cc
61 lines (51 loc) · 959 Bytes
/
timer.cc
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2017, Daniel Thuerck, TU Darmstadt - GCC. All rights reserved.
*
* This software may be modified and distributed under the terms
* of the BSD 3-clause license. See the LICENSE file for details.
*/
#include "timer.h"
_timer::
_timer()
: m_t_start(),
m_t_end()
{
}
_timer::
~_timer()
{
}
void
_timer::
start(
const std::string& s)
{
if(m_t_accu.count(s) == 0)
m_t_accu[s] = 0;
m_t_start[s] = std::chrono::system_clock::now();
}
void
_timer::
stop(
const std::string& s)
{
m_t_end[s] = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = m_t_end[s] - m_t_start[s];
m_t_accu[s] += (elapsed_seconds.count() * 1000);
}
void
_timer::
clear(
const std::string& s)
{
m_t_accu[s] = 0;
}
double
_timer::
get_ms(
const std::string& s)
{
return m_t_accu[s];
}
_timer * __T = new _timer();