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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "gpu/perftests/measurements.h"
6
7 #include "testing/perf/perf_test.h"
8
9 namespace gpu {
10
11 Measurement::Measurement() : name(), wall_time(), cpu_time(), gpu_time() {
12 }
13 Measurement::Measurement(const Measurement& m)
14 : name(m.name),
15 wall_time(m.wall_time),
16 cpu_time(m.cpu_time),
17 gpu_time(m.gpu_time) {
18 }
19 Measurement::Measurement(const std::string& name,
20 const base::TimeDelta wall_time,
21 const base::TimeDelta cpu_time,
22 const base::TimeDelta gpu_time)
23 : name(name), wall_time(wall_time), cpu_time(cpu_time), gpu_time(gpu_time) {
24 }
25
26 void Measurement::PrintResult() const {
27 perf_test::PrintResult(name, "_wall", "", wall_time.InMillisecondsF(), "ms",
28 true);
29 if (cpu_time.InMicroseconds() >= 0) {
30 perf_test::PrintResult(name, "_cpu", "", cpu_time.InMillisecondsF(), "ms",
31 true);
32 }
33 if (gpu_time.InMicroseconds() >= 0) {
34 perf_test::PrintResult(name, "_gpu", "", gpu_time.InMillisecondsF(), "ms",
35 true);
36 }
37 }
38
39 Measurement& Measurement::Increment(const Measurement& m) {
40 wall_time += m.wall_time;
41 cpu_time += m.cpu_time;
42 gpu_time += m.gpu_time;
43 return *this;
44 }
45
46 Measurement Measurement::Divide(int a) const {
47 return Measurement(name, wall_time / a, cpu_time / a, gpu_time / a);
48 }
49
50 Measurement::~Measurement() {
51 }
52
53 MeasurementTimers::MeasurementTimers(GPUTiming* gpu_timing)
54 : wall_time_start_(), cpu_time_start_(), gpu_timer_() {
55 DCHECK(gpu_timing);
56 wall_time_start_ = base::TimeTicks::NowFromSystemTraceTime();
57 if (base::TimeTicks::IsThreadNowSupported()) {
58 cpu_time_start_ = base::TimeTicks::ThreadNow();
59 } else {
60 static bool logged_once = false;
61 LOG_IF(WARNING, !logged_once) << "ThreadNow not supported.";
62 logged_once = true;
63 }
64
65 if (gpu_timing->IsAvailable()) {
66 gpu_timer_.reset(new GPUTimer(gpu_timing));
67 gpu_timer_->Start();
68 }
69 }
70
71 void MeasurementTimers::Record() {
72 wall_time_ = base::TimeTicks::NowFromSystemTraceTime() - wall_time_start_;
73 if (base::TimeTicks::IsThreadNowSupported()) {
74 cpu_time_ = base::TimeTicks::ThreadNow() - cpu_time_start_;
75 }
76 if (gpu_timer_.get()) {
77 gpu_timer_->End();
78 }
79 }
80
81 Measurement MeasurementTimers::GetAsMeasurement(const std::string& name) {
82 DCHECK_NE(base::TimeDelta(),
83 wall_time_); // At least wall_time_ has been set.
84
85 if (!base::TimeTicks::IsThreadNowSupported()) {
86 cpu_time_ = base::TimeDelta::FromMicroseconds(-1);
87 }
88 int64 gpu_time = -1;
89 if (gpu_timer_.get() != nullptr && gpu_timer_->IsAvailable()) {
90 gpu_time = gpu_timer_->GetDeltaElapsed();
91 }
92 return Measurement(name, wall_time_, cpu_time_,
93 base::TimeDelta::FromMicroseconds(gpu_time));
94 }
95
96 MeasurementTimers::~MeasurementTimers() {
97 }
98
99 } // 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