Project
Loading...
Searching...
No Matches
DeviceMetricsInfo.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14#include <cassert>
15#include <cinttypes>
16#include <cstdlib>
17
18#include <algorithm>
19#include <regex>
20#include <string_view>
21#include <tuple>
22#include <iostream>
23
24namespace o2::framework
25{
26
27std::ostream& operator<<(std::ostream& oss, MetricType const& val)
28{
29 switch (val) {
31 oss << "float";
32 break;
34 oss << "string";
35 break;
36 case MetricType::Int:
37 oss << "int";
38 break;
40 oss << "uint64";
41 break;
43 oss << "enum";
44 break;
46 default:
47 oss << "undefined";
48 break;
49 };
50 return oss;
51}
52
53void DeviceMetricsInfoHelpers::clearMetrics(std::vector<DeviceMetricsInfo>& infos)
54{
55 for (auto& info : infos) {
56 info.intMetrics.clear();
57 info.uint64Metrics.clear();
58 info.stringMetrics.clear(); // We do not keep so many strings as metrics as history is less relevant.
59 info.floatMetrics.clear();
60 info.enumMetrics.clear();
61 info.intTimestamps.clear();
62 info.uint64Timestamps.clear();
63 info.floatTimestamps.clear();
64 info.stringTimestamps.clear();
65 info.enumTimestamps.clear();
66 info.max.clear();
67 info.min.clear();
68 info.average.clear();
69 info.minDomain.clear();
70 info.maxDomain.clear();
71 info.metricLabels.clear();
72 info.metricPrefixes.clear();
73 info.metricLabelsAlphabeticallySortedIdx.clear();
74 info.metricLabelsPrefixesSortedIdx.clear();
75 info.metrics.clear();
76 info.changed.clear();
77 }
78}
79
80size_t DeviceMetricsInfoHelpers::metricsStorageSize(std::span<DeviceMetricsInfo const> infos)
81{
82 // Count the size of the metrics storage
83 size_t totalSize = 0;
84 for (auto& info : infos) {
85 totalSize += info.intMetrics.size() * sizeof(MetricsStorage<int>);
86 totalSize += info.uint64Metrics.size() * sizeof(MetricsStorage<uint64_t>);
87 totalSize += info.stringMetrics.size() * sizeof(MetricsStorage<StringMetric>);
88 totalSize += info.floatMetrics.size() * sizeof(MetricsStorage<float>);
89 totalSize += info.enumMetrics.size() * sizeof(MetricsStorage<int8_t>);
90 totalSize += info.intTimestamps.size() * sizeof(TimestampsStorage<int>);
91 totalSize += info.uint64Timestamps.size() * sizeof(TimestampsStorage<uint64_t>);
92 totalSize += info.floatTimestamps.size() * sizeof(TimestampsStorage<float>);
93 totalSize += info.stringTimestamps.size() * sizeof(TimestampsStorage<StringMetric>);
94 totalSize += info.enumTimestamps.size() * sizeof(TimestampsStorage<int8_t>);
95 totalSize += info.max.size() * sizeof(float);
96 totalSize += info.min.size() * sizeof(float);
97 totalSize += info.average.size() * sizeof(float);
98 totalSize += info.minDomain.size() * sizeof(size_t);
99 totalSize += info.maxDomain.size() * sizeof(size_t);
100 totalSize += info.metricLabels.size() * sizeof(MetricLabel);
101 totalSize += info.metricPrefixes.size() * sizeof(MetricPrefix);
102 totalSize += info.metricLabelsAlphabeticallySortedIdx.size() * sizeof(MetricLabelIndex);
103 totalSize += info.metricLabelsPrefixesSortedIdx.size() * sizeof(MetricPrefixIndex);
104 totalSize += info.metrics.size() * sizeof(MetricInfo);
105 totalSize += info.changed.size() * sizeof(bool);
106 }
107
108 return totalSize;
109}
110
111} // namespace o2::framework
GLuint GLfloat * val
Definition glcorearb.h:1582
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::array< size_t, metricStorageSize< T >()> TimestampsStorage
std::ostream & operator<<(std::ostream &s, ChannelType const &type)
Stream operators so that we can use ChannelType with Boost.Test.
std::array< T, metricStorageSize< T >()> MetricsStorage
static size_t metricsStorageSize(std::span< DeviceMetricsInfo const > infos)
static void clearMetrics(std::vector< DeviceMetricsInfo > &infos)