forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceMetricsInfo.cxx
More file actions
111 lines (103 loc) · 3.82 KB
/
DeviceMetricsInfo.cxx
File metadata and controls
111 lines (103 loc) · 3.82 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/DeviceMetricsInfo.h"
#include "Framework/RuntimeError.h"
#include <cassert>
#include <cinttypes>
#include <cstdlib>
#include <algorithm>
#include <regex>
#include <string_view>
#include <tuple>
#include <iostream>
namespace o2::framework
{
std::ostream& operator<<(std::ostream& oss, MetricType const& val)
{
switch (val) {
case MetricType::Float:
oss << "float";
break;
case MetricType::String:
oss << "string";
break;
case MetricType::Int:
oss << "int";
break;
case MetricType::Uint64:
oss << "uint64";
break;
case MetricType::Enum:
oss << "enum";
break;
case MetricType::Unknown:
default:
oss << "undefined";
break;
};
return oss;
}
void DeviceMetricsInfoHelpers::clearMetrics(std::vector<DeviceMetricsInfo>& infos)
{
for (auto& info : infos) {
info.intMetrics.clear();
info.uint64Metrics.clear();
info.stringMetrics.clear(); // We do not keep so many strings as metrics as history is less relevant.
info.floatMetrics.clear();
info.enumMetrics.clear();
info.intTimestamps.clear();
info.uint64Timestamps.clear();
info.floatTimestamps.clear();
info.stringTimestamps.clear();
info.enumTimestamps.clear();
info.max.clear();
info.min.clear();
info.average.clear();
info.minDomain.clear();
info.maxDomain.clear();
info.metricLabels.clear();
info.metricPrefixes.clear();
info.metricLabelsAlphabeticallySortedIdx.clear();
info.metricLabelsPrefixesSortedIdx.clear();
info.metrics.clear();
info.changed.clear();
}
}
size_t DeviceMetricsInfoHelpers::metricsStorageSize(std::span<DeviceMetricsInfo const> infos)
{
// Count the size of the metrics storage
size_t totalSize = 0;
for (auto& info : infos) {
totalSize += info.intMetrics.size() * sizeof(MetricsStorage<int>);
totalSize += info.uint64Metrics.size() * sizeof(MetricsStorage<uint64_t>);
totalSize += info.stringMetrics.size() * sizeof(MetricsStorage<StringMetric>);
totalSize += info.floatMetrics.size() * sizeof(MetricsStorage<float>);
totalSize += info.enumMetrics.size() * sizeof(MetricsStorage<int8_t>);
totalSize += info.intTimestamps.size() * sizeof(TimestampsStorage<int>);
totalSize += info.uint64Timestamps.size() * sizeof(TimestampsStorage<uint64_t>);
totalSize += info.floatTimestamps.size() * sizeof(TimestampsStorage<float>);
totalSize += info.stringTimestamps.size() * sizeof(TimestampsStorage<StringMetric>);
totalSize += info.enumTimestamps.size() * sizeof(TimestampsStorage<int8_t>);
totalSize += info.max.size() * sizeof(float);
totalSize += info.min.size() * sizeof(float);
totalSize += info.average.size() * sizeof(float);
totalSize += info.minDomain.size() * sizeof(size_t);
totalSize += info.maxDomain.size() * sizeof(size_t);
totalSize += info.metricLabels.size() * sizeof(MetricLabel);
totalSize += info.metricPrefixes.size() * sizeof(MetricPrefix);
totalSize += info.metricLabelsAlphabeticallySortedIdx.size() * sizeof(MetricLabelIndex);
totalSize += info.metricLabelsPrefixesSortedIdx.size() * sizeof(MetricPrefixIndex);
totalSize += info.metrics.size() * sizeof(MetricInfo);
totalSize += info.changed.size() * sizeof(bool);
}
return totalSize;
}
} // namespace o2::framework