Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: gpu/perftests/measurements.cc

Issue 960873002: Update from https://crrev.com/318214 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/perftests/measurements.h ('k') | gpu/perftests/texture_upload_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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) {
20 } 20 }
21 Measurement::Measurement(const std::string& name, 21 Measurement::Measurement(const std::string& name,
22 const base::TimeDelta wall_time, 22 const base::TimeDelta wall_time,
23 const base::TimeDelta cpu_time, 23 const base::TimeDelta cpu_time,
24 const base::TimeDelta gpu_time) 24 const base::TimeDelta gpu_time)
25 : name(name), wall_time(wall_time), cpu_time(cpu_time), gpu_time(gpu_time) { 25 : name(name), wall_time(wall_time), cpu_time(cpu_time), gpu_time(gpu_time) {
26 } 26 }
27 27
28 void Measurement::PrintResult() const { 28 void Measurement::PrintResult(const std::string& suffix) const {
29 perf_test::PrintResult(name, "_wall", "", wall_time.InMillisecondsF(), "ms", 29 perf_test::PrintResult(name, "_wall" + suffix, "",
30 true); 30 wall_time.InMillisecondsF(), "ms", true);
31 if (cpu_time.InMicroseconds() >= 0) { 31 if (cpu_time.InMicroseconds() >= 0) {
32 perf_test::PrintResult(name, "_cpu", "", cpu_time.InMillisecondsF(), "ms", 32 perf_test::PrintResult(name, "_cpu" + suffix, "",
33 true); 33 cpu_time.InMillisecondsF(), "ms", true);
34 } 34 }
35 if (gpu_time.InMicroseconds() >= 0) { 35 if (gpu_time.InMicroseconds() >= 0) {
36 perf_test::PrintResult(name, "_gpu", "", gpu_time.InMillisecondsF(), "ms", 36 perf_test::PrintResult(name, "_gpu" + suffix, "",
37 true); 37 gpu_time.InMillisecondsF(), "ms", true);
38 } 38 }
39 } 39 }
40 40
41 Measurement& Measurement::Increment(const Measurement& m) { 41 Measurement& Measurement::Increment(const Measurement& m) {
42 wall_time += m.wall_time; 42 wall_time += m.wall_time;
43 cpu_time += m.cpu_time; 43 cpu_time += m.cpu_time;
44 gpu_time += m.gpu_time; 44 gpu_time += m.gpu_time;
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(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); 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
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
OLDNEW
« no previous file with comments | « gpu/perftests/measurements.h ('k') | gpu/perftests/texture_upload_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698