summaryrefslogtreecommitdiffstats
path: root/benchmarks
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-01-16 00:44:16 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-16 00:44:16 +0000
commit594db0f1b235306d2687395564745888348df808 (patch)
tree958c8f5343bef148d5edaf3266883ef75fb0da30 /benchmarks
parent3159972a80234f7a8e3903cefaeb7719a50f6279 (diff)
parenta763504f9d779391cf19b5259508c28a9e0cd331 (diff)
downloadbionic-594db0f1b235306d2687395564745888348df808.zip
bionic-594db0f1b235306d2687395564745888348df808.tar.gz
bionic-594db0f1b235306d2687395564745888348df808.tar.bz2
Merge "bionic benchmarks: limit benchmark run time to 1s real time"
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/benchmark_main.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/benchmarks/benchmark_main.cpp b/benchmarks/benchmark_main.cpp
index 7140ab6..e922e1e 100644
--- a/benchmarks/benchmark_main.cpp
+++ b/benchmarks/benchmark_main.cpp
@@ -134,19 +134,23 @@ void Benchmark::RunRepeatedlyWithArg(int iterations, int arg) {
}
void Benchmark::RunWithArg(int arg) {
- // run once in case it's expensive
+ // Run once in case it's expensive.
int iterations = 1;
+ int64_t realStartTime = NanoTime();
RunRepeatedlyWithArg(iterations, arg);
- while (g_benchmark_total_time_ns < 1e9 && iterations < 1e9) {
+ int64_t realTotalTime = NanoTime() - realStartTime;
+ while (realTotalTime < 1e9 && iterations < 1e8) {
int last = iterations;
- if (g_benchmark_total_time_ns/iterations == 0) {
+ if (realTotalTime/iterations == 0) {
iterations = 1e9;
} else {
- iterations = 1e9 / (g_benchmark_total_time_ns/iterations);
+ iterations = 1e9 / (realTotalTime/iterations);
}
iterations = std::max(last + 1, std::min(iterations + iterations/2, 100*last));
iterations = Round(iterations);
+ realStartTime = NanoTime();
RunRepeatedlyWithArg(iterations, arg);
+ realTotalTime = NanoTime() - realStartTime;
}
char throughput[100];