Skip to content

Commit

Permalink
fix and test getting reasonable results when comparing more than 2 fu…
Browse files Browse the repository at this point in the history
…nctions (invert permutation bug) (#138)
  • Loading branch information
LilithHafner authored Nov 24, 2024
1 parent ea0fe66 commit 406c5f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/benchmarking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ function _benchmark_2(args1, setup, teardown, gc::Bool, evals::Int, warmup::Bool
t[] = ti
sample
end
ntuple(i -> rp[p[i]], N), t[]
ip = N > 2 ? invperm(p) : p
ntuple(i -> rp[ip[i]], N), t[]
end

_div(a, b) = a == b == 0 ? zero(a/b) : a/b
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ using Random: rand!
@testset "Comparative" begin
x,y = @b .01 sleep,sleep(10*_)
@test x.time < y.time

x,y,z = @b sleep(.001),1+1,1+1
@test x.time > y.time
@test x.time > z.time

x,y,z = @b 1+1,sleep(.001),1+1
@test y.time > x.time
@test y.time > z.time
end
end

Expand Down

0 comments on commit 406c5f1

Please sign in to comment.