OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_PERFTTIMER_H_ | 5 #ifndef BASE_PERFTTIMER_H_ |
6 #define BASE_PERFTTIMER_H_ | 6 #define BASE_PERFTTIMER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // ---------------------------------------------------------------------- | 24 // ---------------------------------------------------------------------- |
25 void LogPerfResult(const char* test_name, double value, const char* units); | 25 void LogPerfResult(const char* test_name, double value, const char* units); |
26 | 26 |
27 // ---------------------------------------------------------------------- | 27 // ---------------------------------------------------------------------- |
28 // PerfTimer | 28 // PerfTimer |
29 // A simple wrapper around Now() | 29 // A simple wrapper around Now() |
30 // ---------------------------------------------------------------------- | 30 // ---------------------------------------------------------------------- |
31 class PerfTimer { | 31 class PerfTimer { |
32 public: | 32 public: |
33 PerfTimer() { | 33 PerfTimer() { |
34 begin_ = TimeTicks::Now(); | 34 begin_ = base::TimeTicks::Now(); |
35 } | 35 } |
36 | 36 |
37 // Returns the time elapsed since object construction | 37 // Returns the time elapsed since object construction |
38 TimeDelta Elapsed() const { | 38 base::TimeDelta Elapsed() const { |
39 return TimeTicks::Now() - begin_; | 39 return base::TimeTicks::Now() - begin_; |
40 } | 40 } |
41 | 41 |
42 private: | 42 private: |
43 TimeTicks begin_; | 43 base::TimeTicks begin_; |
44 }; | 44 }; |
45 | 45 |
46 // ---------------------------------------------------------------------- | 46 // ---------------------------------------------------------------------- |
47 // PerfTimeLogger | 47 // PerfTimeLogger |
48 // Automates calling LogPerfResult for the common case where you want | 48 // Automates calling LogPerfResult for the common case where you want |
49 // to measure the time that something took. Call Done() when the test | 49 // to measure the time that something took. Call Done() when the test |
50 // is complete if you do extra work after the test or there are stack | 50 // is complete if you do extra work after the test or there are stack |
51 // objects with potentially expensive constructors. Otherwise, this | 51 // objects with potentially expensive constructors. Otherwise, this |
52 // class with automatically log on destruction. | 52 // class with automatically log on destruction. |
53 // ---------------------------------------------------------------------- | 53 // ---------------------------------------------------------------------- |
(...skipping 17 matching lines...) Expand all Loading... |
71 logged_ = true; | 71 logged_ = true; |
72 } | 72 } |
73 | 73 |
74 private: | 74 private: |
75 bool logged_; | 75 bool logged_; |
76 std::string test_name_; | 76 std::string test_name_; |
77 PerfTimer timer_; | 77 PerfTimer timer_; |
78 }; | 78 }; |
79 | 79 |
80 #endif // BASE_PERFTTIMER_H_ | 80 #endif // BASE_PERFTTIMER_H_ |
OLD | NEW |