Skip to content

Commit

Permalink
Respect evals even when samples=0 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Apr 6, 2024
1 parent b7e1e12 commit cb6e62c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/benchmarking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ function benchmark(init, setup, f, teardown; evals::Union{Int, Nothing}=nothing,
sample, t
end

samples == 0 && return Benchmark([bench(evals, false)[1]])

warmup, start_time = bench(1, false)

(samples == 0 || seconds == 0) && return Benchmark([warmup])
seconds == 0 && return Benchmark([warmup])

new_evals = if evals === nothing
@assert evals === samples === nothing && seconds !== nothing
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ using Chairmarks: Sample, Benchmark
@testset "low sample count (#91)" begin
b = @be sleep(.001) evals=4 samples=0
@test Chairmarks.only(b.samples).warmup == 0 # Qualify only for compat
@test_broken Chairmarks.only(b.samples).evals == 4
@test Chairmarks.only(b.samples).evals == 4

b = @be sleep(.001) evals=4 samples=1
@test Chairmarks.only(b.samples).warmup == 1
Expand Down

0 comments on commit cb6e62c

Please sign in to comment.