OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 GPU_PERFTESTS_MEASUREMENTS_H_ | 5 #ifndef GPU_PERFTESTS_MEASUREMENTS_H_ |
6 #define GPU_PERFTESTS_MEASUREMENTS_H_ | 6 #define GPU_PERFTESTS_MEASUREMENTS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 | 12 |
| 13 namespace gfx { |
| 14 class GPUTimingClient; |
| 15 class GPUTimer; |
| 16 } |
| 17 |
13 namespace gpu { | 18 namespace gpu { |
14 class GPUTiming; | 19 |
15 class GPUTimer; | |
16 struct Measurement { | 20 struct Measurement { |
17 Measurement(); | 21 Measurement(); |
18 Measurement(const Measurement& m); | 22 Measurement(const Measurement& m); |
19 Measurement(const std::string& name, | 23 Measurement(const std::string& name, |
20 const base::TimeDelta wall_time, | 24 const base::TimeDelta wall_time, |
21 const base::TimeDelta cpu_time, | 25 const base::TimeDelta cpu_time, |
22 const base::TimeDelta gpu_time); | 26 const base::TimeDelta gpu_time); |
23 ~Measurement(); | 27 ~Measurement(); |
24 | 28 |
25 void PrintResult(const std::string& suffix) const; | 29 void PrintResult(const std::string& suffix) const; |
26 Measurement& Increment(const Measurement& m); | 30 Measurement& Increment(const Measurement& m); |
27 Measurement Divide(int a) const; | 31 Measurement Divide(int a) const; |
28 | 32 |
29 std::string name; | 33 std::string name; |
30 base::TimeDelta wall_time; | 34 base::TimeDelta wall_time; |
31 base::TimeDelta cpu_time; | 35 base::TimeDelta cpu_time; |
32 base::TimeDelta gpu_time; | 36 base::TimeDelta gpu_time; |
33 }; | 37 }; |
34 | 38 |
35 // Class to measure wall, cpu and gpu time deltas. | 39 // Class to measure wall, cpu and gpu time deltas. |
36 // The deltas are measured from the time of the object | 40 // The deltas are measured from the time of the object |
37 // creation up to when Record is called. | 41 // creation up to when Record is called. |
38 class MeasurementTimers { | 42 class MeasurementTimers { |
39 public: | 43 public: |
40 explicit MeasurementTimers(GPUTiming* gpu_timing); | 44 explicit MeasurementTimers(gfx::GPUTimingClient* gpu_timing_client); |
41 void Record(); | 45 void Record(); |
42 Measurement GetAsMeasurement(const std::string& name); | 46 Measurement GetAsMeasurement(const std::string& name); |
43 ~MeasurementTimers(); | 47 ~MeasurementTimers(); |
44 | 48 |
45 private: | 49 private: |
46 base::TimeTicks wall_time_start_; | 50 base::TimeTicks wall_time_start_; |
47 base::TimeTicks cpu_time_start_; | 51 base::TimeTicks cpu_time_start_; |
48 scoped_ptr<gpu::GPUTimer> gpu_timer_; | 52 scoped_ptr<gfx::GPUTimer> gpu_timer_; |
49 | 53 |
50 base::TimeDelta wall_time_; | 54 base::TimeDelta wall_time_; |
51 base::TimeDelta cpu_time_; | 55 base::TimeDelta cpu_time_; |
52 }; | 56 }; |
53 | 57 |
54 } // namespace gpu | 58 } // namespace gpu |
55 | 59 |
56 #endif // GPU_PERFTESTS_MEASUREMENTS_H_ | 60 #endif // GPU_PERFTESTS_MEASUREMENTS_H_ |
OLD | NEW |