aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar cdalton <cdalton@nvidia.com>2015-06-25 19:17:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-06-25 19:17:08 -0700
commite1b8958877a512bf83cbc2c72bb31e7d71b06f43 (patch)
tree91db5defa35079fe6b7397a02a8ed7a1b170abde /tools
parent1852ec2b46a2a0efbb3550ff4d8b640f56a810e9 (diff)
Add samplingTime mode to nanobench
Adds a nanobench mode that takes samples for a fixed amount of time, rather than taking a fixed amount of samples. BUG=skia: Review URL: https://codereview.chromium.org/1204153002
Diffstat (limited to 'tools')
-rw-r--r--tools/Stats.h17
-rw-r--r--tools/VisualBench.cpp2
2 files changed, 16 insertions, 3 deletions
diff --git a/tools/Stats.h b/tools/Stats.h
index 8487a9497d..12c1d35e1f 100644
--- a/tools/Stats.h
+++ b/tools/Stats.h
@@ -1,3 +1,10 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
#ifndef Stats_DEFINED
#define Stats_DEFINED
@@ -11,7 +18,13 @@
#endif
struct Stats {
- Stats(const double samples[], int n) {
+ Stats(const SkTArray<double>& samples) {
+ int n = samples.count();
+ if (!n) {
+ min = max = mean = var = median = 0;
+ return;
+ }
+
min = samples[0];
max = samples[0];
for (int i = 0; i < n; i++) {
@@ -32,7 +45,7 @@ struct Stats {
var = err / (n-1);
SkAutoTMalloc<double> sorted(n);
- memcpy(sorted.get(), samples, n * sizeof(double));
+ memcpy(sorted.get(), samples.begin(), n * sizeof(double));
SkTQSort(sorted.get(), sorted.get() + n - 1);
median = sorted[n/2];
diff --git a/tools/VisualBench.cpp b/tools/VisualBench.cpp
index cbc8994592..ac53b43167 100644
--- a/tools/VisualBench.cpp
+++ b/tools/VisualBench.cpp
@@ -152,7 +152,7 @@ void VisualBench::printStats() {
SkDebugf("%s\n", shortName.c_str());
} else {
SkASSERT(measurements.count());
- Stats stats(measurements.begin(), measurements.count());
+ Stats stats(measurements);
const double stdDevPercent = 100 * sqrt(stats.var) / stats.mean;
SkDebugf("%4d/%-4dMB\t%d\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\n",
sk_tools::getCurrResidentSetSizeMB(),