blob: b8e87f3a9abe4a3238bb5882647a2ae251e41619 [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#ifndef ML_TIME_METRICS_H_
6#define ML_TIME_METRICS_H_
7
8#include <string>
9
10#include <base/time/time.h>
11
12namespace ml {
13
14// An RAII class to measure the wall time usage of a scope.
15// The starting time is measured in constructor. And the ending time is measured
16// and reported in destructor.
17class WallTimeMetric {
18 public:
19 explicit WallTimeMetric(const std::string& name);
20 ~WallTimeMetric();
21
22 private:
23 const std::string metric_name_;
24 const base::Time start_time_;
25};
26
27} // namespace ml
28#endif // ML_TIME_METRICS_H_