am cb41ce5f: am 594db0f1: Merge "bionic benchmarks: limit benchmark run time to 1s real time"
* commit 'cb41ce5f4e942dce66defb76f25b2e7d61f8ab8d': bionic benchmarks: limit benchmark run time to 1s real time
This commit is contained in:
commit
927875a7d0
@ -134,19 +134,23 @@ void Benchmark::RunRepeatedlyWithArg(int iterations, int arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Benchmark::RunWithArg(int arg) {
|
void Benchmark::RunWithArg(int arg) {
|
||||||
// run once in case it's expensive
|
// Run once in case it's expensive.
|
||||||
int iterations = 1;
|
int iterations = 1;
|
||||||
|
int64_t realStartTime = NanoTime();
|
||||||
RunRepeatedlyWithArg(iterations, arg);
|
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;
|
int last = iterations;
|
||||||
if (g_benchmark_total_time_ns/iterations == 0) {
|
if (realTotalTime/iterations == 0) {
|
||||||
iterations = 1e9;
|
iterations = 1e9;
|
||||||
} else {
|
} 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 = std::max(last + 1, std::min(iterations + iterations/2, 100*last));
|
||||||
iterations = Round(iterations);
|
iterations = Round(iterations);
|
||||||
|
realStartTime = NanoTime();
|
||||||
RunRepeatedlyWithArg(iterations, arg);
|
RunRepeatedlyWithArg(iterations, arg);
|
||||||
|
realTotalTime = NanoTime() - realStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
char throughput[100];
|
char throughput[100];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user