forked from bristolcrypto/SPDZ-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoryUsage.h
48 lines (38 loc) · 853 Bytes
/
MemoryUsage.h
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
// (C) 2017 University of Bristol. See License.txt
/*
* MemoryUsage.h
*
*/
#ifndef TOOLS_MEMORYUSAGE_H_
#define TOOLS_MEMORYUSAGE_H_
#include <map>
using namespace std;
class MemoryUsage
{
map<string, size_t> usage;
public:
MemoryUsage& operator+=(const MemoryUsage& other)
{
for (auto& it : other.usage)
usage[it.first] += it.second;
return *this;
}
void update(const string& tag, size_t size)
{
usage[tag] = max(size, usage[tag]);
}
void add(const string& tag, size_t size)
{
usage[tag] += size;
}
size_t get(const string& tag)
{
return usage[tag];
}
void print()
{
for (auto& it : usage)
cout << it.first << " required: " << 1e-9 * it.second << " (GB)" << endl;
}
};
#endif /* TOOLS_MEMORYUSAGE_H_ */