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 "testing/perf/perf_test.h" | 8 #include "testing/perf/perf_test.h" |
9 #include "ui/gl/gpu_timing.h" | 9 #include "ui/gl/gpu_timing.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(gfx::GPUTimingClient* gpu_timing_client) | 55 MeasurementTimers::MeasurementTimers(gfx::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_client); | 57 DCHECK(gpu_timing_client); |
58 wall_time_start_ = base::TimeTicks::NowFromSystemTraceTime(); | 58 wall_time_start_ = base::TraceTicks::Now(); |
59 if (base::TimeTicks::IsThreadNowSupported()) { | 59 if (base::ThreadTicks::IsSupported()) { |
60 cpu_time_start_ = base::TimeTicks::ThreadNow(); | 60 cpu_time_start_ = base::ThreadTicks::Now(); |
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) << "ThreadTicks not supported."; |
64 logged_once = true; | 64 logged_once = true; |
65 } | 65 } |
66 | 66 |
67 if (gpu_timing_client->IsAvailable()) { | 67 if (gpu_timing_client->IsAvailable()) { |
68 gpu_timer_ = gpu_timing_client->CreateGPUTimer(); | 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::TraceTicks::Now() - wall_time_start_; |
75 if (base::TimeTicks::IsThreadNowSupported()) { | 75 if (base::ThreadTicks::IsSupported()) { |
76 cpu_time_ = base::TimeTicks::ThreadNow() - cpu_time_start_; | 76 cpu_time_ = base::ThreadTicks::Now() - cpu_time_start_; |
77 } | 77 } |
78 if (gpu_timer_.get()) { | 78 if (gpu_timer_.get()) { |
79 gpu_timer_->End(); | 79 gpu_timer_->End(); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 Measurement MeasurementTimers::GetAsMeasurement(const std::string& name) { | 83 Measurement MeasurementTimers::GetAsMeasurement(const std::string& name) { |
84 DCHECK_NE(base::TimeDelta(), | 84 DCHECK_NE(base::TimeDelta(), |
85 wall_time_); // At least wall_time_ has been set. | 85 wall_time_); // At least wall_time_ has been set. |
86 | 86 |
87 if (!base::TimeTicks::IsThreadNowSupported()) { | 87 if (!base::ThreadTicks::IsSupported()) { |
88 cpu_time_ = base::TimeDelta::FromMicroseconds(-1); | 88 cpu_time_ = base::TimeDelta::FromMicroseconds(-1); |
89 } | 89 } |
90 int64 gpu_time = -1; | 90 int64 gpu_time = -1; |
91 if (gpu_timer_.get() != nullptr && gpu_timer_->IsAvailable()) { | 91 if (gpu_timer_.get() != nullptr && gpu_timer_->IsAvailable()) { |
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 if (gpu_timer_.get()) { | 99 if (gpu_timer_.get()) { |
100 gpu_timer_->Destroy(true); | 100 gpu_timer_->Destroy(true); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 } // namespace gpu | 104 } // namespace gpu |
OLD | NEW |