blob: 2abf62fd739015c0d0deed037a9339fbec70527a (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
//===-- MemoryGauge.h -------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef __PerfTestDriver__MemoryGauge__
#define __PerfTestDriver__MemoryGauge__
#include "Gauge.h"
#include "Results.h"
#include <mach/task_info.h>
namespace lldb_perf {
class MemoryStats {
public:
MemoryStats(mach_vm_size_t virtual_size = 0, mach_vm_size_t resident_size = 0,
mach_vm_size_t max_resident_size = 0);
MemoryStats(const MemoryStats &rhs);
MemoryStats &operator=(const MemoryStats &rhs);
MemoryStats &operator+=(const MemoryStats &rhs);
MemoryStats operator-(const MemoryStats &rhs);
MemoryStats operator+(const MemoryStats &rhs);
MemoryStats operator/(size_t rhs);
MemoryStats operator*(const MemoryStats &rhs);
mach_vm_size_t GetVirtualSize() const { return m_virtual_size; }
mach_vm_size_t GetResidentSize() const { return m_resident_size; }
mach_vm_size_t GetMaxResidentSize() const { return m_max_resident_size; }
void SetVirtualSize(mach_vm_size_t vs) { m_virtual_size = vs; }
void SetResidentSize(mach_vm_size_t rs) { m_resident_size = rs; }
void SetMaxResidentSize(mach_vm_size_t mrs) { m_max_resident_size = mrs; }
Results::ResultSP GetResult(const char *name, const char *description) const;
private:
mach_vm_size_t m_virtual_size;
mach_vm_size_t m_resident_size;
mach_vm_size_t m_max_resident_size;
};
class MemoryGauge : public Gauge<MemoryStats> {
public:
MemoryGauge();
virtual ~MemoryGauge() {}
void Start();
ValueType Stop();
virtual ValueType GetStartValue() const { return m_start; }
virtual ValueType GetStopValue() const { return m_stop; }
virtual ValueType GetDeltaValue() const;
private:
enum class State { eNeverUsed, eCounting, eStopped };
ValueType Now();
State m_state;
ValueType m_start;
ValueType m_stop;
ValueType m_delta;
};
template <>
Results::ResultSP GetResult(const char *description, MemoryStats value);
} // namespace lldb_perf
lldb_perf::MemoryStats sqrt(const lldb_perf::MemoryStats &arg);
#endif // #ifndef __PerfTestDriver__MemoryGauge__
|