blob: 403b2723acf4f43f7db3c9154de2912f8a9e7d6d [file] [log] [blame]
[email protected]9db9c912013-09-17 00:34:381// Copyright 2013 The Chromium 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 BASE_TEST_PERF_TIME_LOGGER_H_
6#define BASE_TEST_PERF_TIME_LOGGER_H_
7
8#include <string>
9
10#include "base/basictypes.h"
[email protected]bd5a3742013-09-29 18:06:1311#include "base/timer/elapsed_timer.h"
[email protected]9db9c912013-09-17 00:34:3812
13namespace base {
14
15// Automates calling LogPerfResult for the common case where you want
16// to measure the time that something took. Call Done() when the test
17// is complete if you do extra work after the test or there are stack
18// objects with potentially expensive constructors. Otherwise, this
19// class with automatically log on destruction.
20class PerfTimeLogger {
21 public:
22 explicit PerfTimeLogger(const char* test_name);
23 ~PerfTimeLogger();
24
25 void Done();
26
27 private:
28 bool logged_;
29 std::string test_name_;
[email protected]bd5a3742013-09-29 18:06:1330 ElapsedTimer timer_;
[email protected]9db9c912013-09-17 00:34:3831
32 DISALLOW_COPY_AND_ASSIGN(PerfTimeLogger);
33};
34
35} // namespace base
36
37#endif // BASE_TEST_PERF_TIME_LOGGER_H_