aboutsummaryrefslogtreecommitdiffstats
path: root/vbench/src/vbench/core/timer.cpp
blob: 894415c5db50c1ae43423dfc5072304f414f42c3 (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "timer.h"

namespace vbench {

Timer::Timer()
    : _zero(clock::now())
{
}

void
Timer::reset()
{
    _zero = clock::now();
}

double
Timer::sample() const
{
    using seconds = std::chrono::duration<double>;
    seconds seconds_since_zero = (clock::now() - _zero);
    return seconds_since_zero.count();
}

} // namespace vbench