blob: 90cbe08d4a1a57842c00d3a07a069bde5c932212 [file] [log] [blame]
Honglin Yu21616692021-05-14 11:20:22 +10001// Copyright 2021 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ml/time_metrics.h"
6
7#include <metrics/metrics_library.h>
8
9namespace ml {
10
11namespace {
12// UMA histogram range for wall time metrics.
13constexpr int kWallTimeMinMicrosec = 1; // 1 μs
14constexpr int kWallTimeMaxMicrosec = 1800000000; // 30 min
15constexpr int kWallTimeBuckets = 100;
16} // namespace
17
18WallTimeMetric::WallTimeMetric(const std::string& name)
19 : metric_name_(name), start_time_(base::Time::Now()) {}
20
21WallTimeMetric::~WallTimeMetric() {
22 MetricsLibrary().SendToUMA(
23 metric_name_, (base::Time::Now() - start_time_).InMicroseconds(),
24 kWallTimeMinMicrosec, kWallTimeMaxMicrosec, kWallTimeBuckets);
25}
26
27} // namespace ml