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::TraceTicks::Now(); | 58 wall_time_start_ = base::TimeTicks::Now(); |
59 if (base::ThreadTicks::IsSupported()) { | 59 if (base::ThreadTicks::IsSupported()) { |
60 base::ThreadTicks::WaitUntilInitialized(); | 60 base::ThreadTicks::WaitUntilInitialized(); |
61 cpu_time_start_ = base::ThreadTicks::Now(); | 61 cpu_time_start_ = base::ThreadTicks::Now(); |
62 } else { | 62 } else { |
63 static bool logged_once = false; | 63 static bool logged_once = false; |
64 LOG_IF(WARNING, !logged_once) << "ThreadTicks not supported."; | 64 LOG_IF(WARNING, !logged_once) << "ThreadTicks not supported."; |
65 logged_once = true; | 65 logged_once = true; |
66 } | 66 } |
67 | 67 |
68 if (gpu_timing_client->IsAvailable()) { | 68 if (gpu_timing_client->IsAvailable()) { |
69 gpu_timer_ = gpu_timing_client->CreateGPUTimer(true); | 69 gpu_timer_ = gpu_timing_client->CreateGPUTimer(true); |
70 gpu_timer_->Start(); | 70 gpu_timer_->Start(); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void MeasurementTimers::Record() { | 74 void MeasurementTimers::Record() { |
75 wall_time_ = base::TraceTicks::Now() - wall_time_start_; | 75 wall_time_ = base::TimeTicks::Now() - wall_time_start_; |
76 if (base::ThreadTicks::IsSupported()) { | 76 if (base::ThreadTicks::IsSupported()) { |
77 cpu_time_ = base::ThreadTicks::Now() - cpu_time_start_; | 77 cpu_time_ = base::ThreadTicks::Now() - cpu_time_start_; |
78 } | 78 } |
79 if (gpu_timer_.get()) { | 79 if (gpu_timer_.get()) { |
80 gpu_timer_->End(); | 80 gpu_timer_->End(); |
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 Measurement MeasurementTimers::GetAsMeasurement(const std::string& name) { | 84 Measurement MeasurementTimers::GetAsMeasurement(const std::string& name) { |
85 DCHECK_NE(base::TimeDelta(), | 85 DCHECK_NE(base::TimeDelta(), |
(...skipping 10 matching lines...) Expand all Loading... |
96 base::TimeDelta::FromMicroseconds(gpu_time)); | 96 base::TimeDelta::FromMicroseconds(gpu_time)); |
97 } | 97 } |
98 | 98 |
99 MeasurementTimers::~MeasurementTimers() { | 99 MeasurementTimers::~MeasurementTimers() { |
100 if (gpu_timer_.get()) { | 100 if (gpu_timer_.get()) { |
101 gpu_timer_->Destroy(true); | 101 gpu_timer_->Destroy(true); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 } // namespace gpu | 105 } // namespace gpu |
OLD | NEW |