blob: e14685647a60533670b7448579af8d1f107ed79e [file] [log] [blame]
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "metrics.h"
#include "android-base/logging.h"
#include "base/macros.h"
#pragma clang diagnostic push
#pragma clang diagnostic error "-Wconversion"
namespace art {
namespace metrics {
std::string DatumName(DatumId datum) {
switch (datum) {
#define ART_COUNTER(name) \
case DatumId::k##name: \
return #name;
ART_COUNTERS(ART_COUNTER)
#undef ART_COUNTER
#define ART_HISTOGRAM(name, num_buckets, low_value, high_value) \
case DatumId::k##name: \
return #name;
ART_HISTOGRAMS(ART_HISTOGRAM)
#undef ART_HISTOGRAM
default:
LOG(FATAL) << "Unknown datum id: " << static_cast<unsigned>(datum);
UNREACHABLE();
}
}
ArtMetrics::ArtMetrics() : unused_ {}
#define ART_COUNTER(name) \
, name##_ {}
ART_COUNTERS(ART_COUNTER)
#undef ART_COUNTER
#define ART_HISTOGRAM(name, num_buckets, low_value, high_value) \
, name##_ {}
ART_HISTOGRAMS(ART_HISTOGRAM)
#undef ART_HISTOGRAM
{
}
void ArtMetrics::ReportAllMetrics(MetricsBackend* backend) const {
// Dump counters
#define ART_COUNTER(name) name()->Report(backend);
ART_COUNTERS(ART_COUNTER)
#undef ART_COUNTERS
// Dump histograms
#define ART_HISTOGRAM(name, num_buckets, low_value, high_value) name()->Report(backend);
ART_HISTOGRAMS(ART_HISTOGRAM)
#undef ART_HISTOGRAM
}
} // namespace metrics
} // namespace art
#pragma clang diagnostic pop // -Wconversion