Can I build several inter-depending benchmarks from a serial procedure in “one go” using BenchmarkTools.jl ?
Say I have the following functionality laid out in a function
function mymutatingfunc!(x)
mutfunc1!(x)
mutfunc2!(x)
mutfunc3!(x)
end
and x
needs to be initialized x = init()
All mutfunc!
s need to be called in that order, otherwise they don’t make sense.
E.g., mutfunc3!
can operate normally only if mutfunc1!
,mutfunc2!
are called in beforehand.
Current solution
I would like to benchmark all mutfunc!
s individually.
This is complex because it would be something like
x = init()
SUITE["muttfunc1"] = @benchmarkable muttfunc1!(y) setup=(y = x |> deepcopy)
SUITE["muttfunc2"] = @benchmarkable muttfunc2!(y) setup=(y = x |> deepcopy |> mutfunc1!)
SUITE["muttfunc3"] = @benchmarkable muttfunc3!(y) setup=(y = x |> deepcopy |> mutfunc1! |> mutfunc2!)
This looks like a waste of resources.
Repeatedly calling mtfunc!
is also not possible as the content changes significantly.
E.g. I cannot do something like
x = init()
SUITE["muttfunc1"] = @benchmarkable muttfunc1!(y) setup=(y = x |> deepcopy)
muttfunc1!(x)
SUITE["muttfunc2"] = @benchmarkable muttfunc2!(y) setup=(y = x |> deepcopy)
muttfunc2!(x)
SUITE["muttfunc3"] = @benchmarkable muttfunc3!(y) setup=(y = x |> deepcopy)
Desirable
Could I “asychronously” build the benchmarks by sampling in a round-robin fashion.
E.g., it would be awesome if I could do something like
x = init()
@startbenchmark SUITE setup=(y=deepcopy(x))
@yieldbenchmeasure "muttfunc1" muttfunc1!(y)
@yieldbenchmeasure "muttfunc2" muttfunc2!(y)
@yieldbenchmeasure "muttfunc3" muttfunc3!(y)
end
Ofc it’s understandable they will all need to have the same benchmark config (e.g. samples
, evals
).
I hope my imaginery code is understandable of what it is meant to accomplish.