diff options
-rw-r--r-- | tools/monobench.cpp | 14 |
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); |