Skip to content

Commit 5f019c2

Browse files
authored
Merge pull request #326 from Shopify/rwstauner/profile-n
Only fetch MIN_BENCH_ITRS once
2 parents 4870ffd + 963097c commit 5f019c2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

harness/harness-extra.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ def get_time
6565
# but allow that to be overridden by MIN_BENCH_ITRS env var.
6666
# Also use MIN_BENCH_TIME to loop until the benchmark has run for a sufficient duration.
6767
def run_enough_to_profile(n, &block)
68+
# Allow MIN_BENCH_ITRS to override the argument.
69+
n = ENV.fetch('MIN_BENCH_ITRS', n).to_i
70+
6871
start = get_time
6972
loop do
70-
# Allow MIN_BENCH_ITRS to override the argument.
71-
n = ENV.fetch('MIN_BENCH_ITRS', n).to_i
7273
n.times(&block)
7374

7475
break if (get_time - start) >= MIN_BENCH_TIME

0 commit comments

Comments
 (0)