aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-09-28 14:00:51 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-09-28 19:35:50 +0000
commit645999fe7808fa7bdbb6df6dfcbbeb974d1de933 (patch)
tree379a02b2fb4cd9d3ff2945b9065fb3638d3b8a9c /tools
parent2384cfaa5da6d58775f4789ddb451259759c026c (diff)
monobench: usability tweaks
- Allow an second argument to limit the number of samples. - If no benchmarks match, warn and exit instead of infinitely looping. The default limit of 2147483647 10ms samples will run for 9 months, which I think is long enough to not need any special infinity logic. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2747 Change-Id: Id70cf77b624e19dc04e1d75a71385aee3c988a80 Reviewed-on: https://skia-review.googlesource.com/2747 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/monobench.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tools/monobench.cpp b/tools/monobench.cpp
index 88a6cce37c..756e24f101 100644
--- a/tools/monobench.cpp
+++ b/tools/monobench.cpp
@@ -12,6 +12,7 @@
#include <chrono>
#include <regex>
#include <stdio.h>
+#include <stdlib.h>
#include <string>
#include <vector>
@@ -23,9 +24,9 @@ int main(int argc, char** argv) {
using ns = std::chrono::duration<double, std::nano>;
std::regex pattern;
- if (argc > 1) {
- pattern = argv[1];
- }
+ int limit = 2147483647;
+ if (argc > 1) { pattern = argv[1]; }
+ if (argc > 2) { limit = atoi(argv[2]); }
struct Bench {
std::unique_ptr<Benchmark> b;
@@ -45,6 +46,11 @@ int main(int argc, char** argv) {
}
}
+ if (benches.size() == 0) {
+ printf("No bench matched.\n");
+ return 1;
+ }
+
if (benches.size() > 1) {
int common_prefix = benches[0].name.size();
for (size_t i = 1; i < benches.size(); i++) {
@@ -78,7 +84,7 @@ int main(int argc, char** argv) {
}
int samples = 0;
- for (;;) {
+ while (samples < limit) {
for (auto& bench : benches) {
for (int loops = 1; loops < 1000000000;) {
bench.b->preDraw(nullptr);