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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/perftests/measurements.h ('k') | gpu/perftests/texture_upload_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/perftests/measurements.cc
diff --git a/gpu/perftests/measurements.cc b/gpu/perftests/measurements.cc
new file mode 100644
index 0000000000000000000000000000000000000000..270e459d55d7cbffacb029b5dad9841498d5fd4d
--- /dev/null
+++ b/gpu/perftests/measurements.cc
@@ -0,0 +1,99 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gpu/perftests/measurements.h"
+
+#include "testing/perf/perf_test.h"
+
+namespace gpu {
+
+Measurement::Measurement() : name(), wall_time(), cpu_time(), gpu_time() {
+}
+Measurement::Measurement(const Measurement& m)
+ : name(m.name),
+ wall_time(m.wall_time),
+ cpu_time(m.cpu_time),
+ gpu_time(m.gpu_time) {
+}
+Measurement::Measurement(const std::string& name,
+ const base::TimeDelta wall_time,
+ const base::TimeDelta cpu_time,
+ const base::TimeDelta gpu_time)
+ : name(name), wall_time(wall_time), cpu_time(cpu_time), gpu_time(gpu_time) {
+}
+
+void Measurement::PrintResult() const {
+ perf_test::PrintResult(name, "_wall", "", wall_time.InMillisecondsF(), "ms",
+ true);
+ if (cpu_time.InMicroseconds() >= 0) {
+ perf_test::PrintResult(name, "_cpu", "", cpu_time.InMillisecondsF(), "ms",
+ true);
+ }
+ if (gpu_time.InMicroseconds() >= 0) {
+ perf_test::PrintResult(name, "_gpu", "", gpu_time.InMillisecondsF(), "ms",
+ true);
+ }
+}
+
+Measurement& Measurement::Increment(const Measurement& m) {
+ wall_time += m.wall_time;
+ cpu_time += m.cpu_time;
+ gpu_time += m.gpu_time;
+ return *this;
+}
+
+Measurement Measurement::Divide(int a) const {
+ return Measurement(name, wall_time / a, cpu_time / a, gpu_time / a);
+}
+
+Measurement::~Measurement() {
+}
+
+MeasurementTimers::MeasurementTimers(GPUTiming* gpu_timing)
+ : wall_time_start_(), cpu_time_start_(), gpu_timer_() {
+ DCHECK(gpu_timing);
+ wall_time_start_ = base::TimeTicks::NowFromSystemTraceTime();
+ if (base::TimeTicks::IsThreadNowSupported()) {
+ cpu_time_start_ = base::TimeTicks::ThreadNow();
+ } else {
+ static bool logged_once = false;
+ LOG_IF(WARNING, !logged_once) << "ThreadNow not supported.";
+ logged_once = true;
+ }
+
+ if (gpu_timing->IsAvailable()) {
+ gpu_timer_.reset(new GPUTimer(gpu_timing));
+ gpu_timer_->Start();
+ }
+}
+
+void MeasurementTimers::Record() {
+ wall_time_ = base::TimeTicks::NowFromSystemTraceTime() - wall_time_start_;
+ if (base::TimeTicks::IsThreadNowSupported()) {
+ cpu_time_ = base::TimeTicks::ThreadNow() - cpu_time_start_;
+ }
+ if (gpu_timer_.get()) {
+ gpu_timer_->End();
+ }
+}
+
+Measurement MeasurementTimers::GetAsMeasurement(const std::string& name) {
+ DCHECK_NE(base::TimeDelta(),
+ wall_time_); // At least wall_time_ has been set.
+
+ if (!base::TimeTicks::IsThreadNowSupported()) {
+ cpu_time_ = base::TimeDelta::FromMicroseconds(-1);
+ }
+ int64 gpu_time = -1;
+ if (gpu_timer_.get() != nullptr && gpu_timer_->IsAvailable()) {
+ gpu_time = gpu_timer_->GetDeltaElapsed();
+ }
+ return Measurement(name, wall_time_, cpu_time_,
+ base::TimeDelta::FromMicroseconds(gpu_time));
+}
+
+MeasurementTimers::~MeasurementTimers() {
+}
+
+} // namespace gpu
« 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