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 #include "gpu/perftests/measurements.h" | 5 #include "gpu/perftests/measurements.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gpu/command_buffer/service/gpu_timing.h" | |
9 #include "testing/perf/perf_test.h" | 8 #include "testing/perf/perf_test.h" |
| 9 #include "ui/gl/gpu_timing.h" |
10 | 10 |
11 namespace gpu { | 11 namespace gpu { |
12 | 12 |
13 Measurement::Measurement() : name(), wall_time(), cpu_time(), gpu_time() { | 13 Measurement::Measurement() : name(), wall_time(), cpu_time(), gpu_time() { |
14 } | 14 } |
15 Measurement::Measurement(const Measurement& m) | 15 Measurement::Measurement(const Measurement& m) |
16 : name(m.name), | 16 : name(m.name), |
17 wall_time(m.wall_time), | 17 wall_time(m.wall_time), |
18 cpu_time(m.cpu_time), | 18 cpu_time(m.cpu_time), |
19 gpu_time(m.gpu_time) { | 19 gpu_time(m.gpu_time) { |
(...skipping 25 matching lines...) Expand all Loading... |
45 return *this; | 45 return *this; |
46 } | 46 } |
47 | 47 |
48 Measurement Measurement::Divide(int a) const { | 48 Measurement Measurement::Divide(int a) const { |
49 return Measurement(name, wall_time / a, cpu_time / a, gpu_time / a); | 49 return Measurement(name, wall_time / a, cpu_time / a, gpu_time / a); |
50 } | 50 } |
51 | 51 |
52 Measurement::~Measurement() { | 52 Measurement::~Measurement() { |
53 } | 53 } |
54 | 54 |
55 MeasurementTimers::MeasurementTimers(GPUTiming* gpu_timing) | 55 MeasurementTimers::MeasurementTimers(GPUTimingClient* gpu_timing_client) |
56 : wall_time_start_(), cpu_time_start_(), gpu_timer_() { | 56 : wall_time_start_(), cpu_time_start_(), gpu_timer_() { |
57 DCHECK(gpu_timing); | 57 DCHECK(gpu_timing_client); |
58 wall_time_start_ = base::TimeTicks::NowFromSystemTraceTime(); | 58 wall_time_start_ = base::TimeTicks::NowFromSystemTraceTime(); |
59 if (base::TimeTicks::IsThreadNowSupported()) { | 59 if (base::TimeTicks::IsThreadNowSupported()) { |
60 cpu_time_start_ = base::TimeTicks::ThreadNow(); | 60 cpu_time_start_ = base::TimeTicks::ThreadNow(); |
61 } else { | 61 } else { |
62 static bool logged_once = false; | 62 static bool logged_once = false; |
63 LOG_IF(WARNING, !logged_once) << "ThreadNow not supported."; | 63 LOG_IF(WARNING, !logged_once) << "ThreadNow not supported."; |
64 logged_once = true; | 64 logged_once = true; |
65 } | 65 } |
66 | 66 |
67 if (gpu_timing->IsAvailable()) { | 67 if (gpu_timing_client->IsAvailable()) { |
68 gpu_timer_.reset(new GPUTimer(gpu_timing)); | 68 gpu_timer_ = gpu_timing_client->CreateGPUTimer(); |
69 gpu_timer_->Start(); | 69 gpu_timer_->Start(); |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 void MeasurementTimers::Record() { | 73 void MeasurementTimers::Record() { |
74 wall_time_ = base::TimeTicks::NowFromSystemTraceTime() - wall_time_start_; | 74 wall_time_ = base::TimeTicks::NowFromSystemTraceTime() - wall_time_start_; |
75 if (base::TimeTicks::IsThreadNowSupported()) { | 75 if (base::TimeTicks::IsThreadNowSupported()) { |
76 cpu_time_ = base::TimeTicks::ThreadNow() - cpu_time_start_; | 76 cpu_time_ = base::TimeTicks::ThreadNow() - cpu_time_start_; |
77 } | 77 } |
78 if (gpu_timer_.get()) { | 78 if (gpu_timer_.get()) { |
(...skipping 13 matching lines...) Expand all Loading... |
92 gpu_time = gpu_timer_->GetDeltaElapsed(); | 92 gpu_time = gpu_timer_->GetDeltaElapsed(); |
93 } | 93 } |
94 return Measurement(name, wall_time_, cpu_time_, | 94 return Measurement(name, wall_time_, cpu_time_, |
95 base::TimeDelta::FromMicroseconds(gpu_time)); | 95 base::TimeDelta::FromMicroseconds(gpu_time)); |
96 } | 96 } |
97 | 97 |
98 MeasurementTimers::~MeasurementTimers() { | 98 MeasurementTimers::~MeasurementTimers() { |
99 } | 99 } |
100 | 100 |
101 } // namespace gpu | 101 } // namespace gpu |
OLD | NEW |