aboutsummaryrefslogtreecommitdiffhomepage
path: root/bench/nanobench.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bench/nanobench.cpp')
-rw-r--r--bench/nanobench.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index d784439bb4..04583309ce 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -1284,6 +1284,15 @@ int main(int argc, char** argv) {
? setup_gpu_bench(target, bench.get(), maxFrameLag)
: setup_cpu_bench(overhead, target, bench.get());
+ if (runs == 0 && FLAGS_ms < 1000) {
+ // Run the first bench for 1000ms to warm up the nanobench if FLAGS_ms < 1000.
+ // Otherwise, the first few benches' measurements will be inaccurate.
+ auto stop = now_ms() + 1000;
+ do {
+ time(loops, bench.get(), target);
+ } while (now_ms() < stop);
+ }
+
if (FLAGS_ms) {
samples.reset();
auto stop = now_ms() + FLAGS_ms;