blob: 59871aab4ce7b2467de8db549b77f819f3a9d833 (
plain)
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
|
//
// Timer.cpp
// PerfTestDriver
//
// Created by Enrico Granata on 3/6/13.
// Copyright (c) 2013 Apple Inc. All rights reserved.
//
#include "Timer.h"
#include <assert.h>
using namespace lldb::perf;
TimeGauge::HPTime
TimeGauge::now ()
{
return high_resolution_clock::now();
}
TimeGauge::TimeGauge () :
m_start(),
m_state(TimeGauge::State::eTSNeverUsed)
{
}
void
TimeGauge::start ()
{
m_state = TimeGauge::State::eTSCounting;
m_start = now();
}
double
TimeGauge::stop ()
{
auto stop = now();
assert(m_state == TimeGauge::State::eTSCounting && "cannot stop a non-started clock");
m_state = TimeGauge::State::eTSStopped;
return (m_value = duration_cast<duration<double>>(stop-m_start).count());
}
double
TimeGauge::value ()
{
assert(m_state == TimeGauge::State::eTSStopped && "clock must be used before you can evaluate it");
return m_value;
}
|