I have a package with an exported function that I want to benchmark.
When I run the function without the @btime
macro, it executes flawlessly. With the macro, however, it seems to mess with the input arguments in a way where an exception is triggered that I wrote myself:
using MyPackage
using BenchmarkTools
observables = [(x,p,force) -> x[1], (x,p,force) -> x[2]]
observable_names = ["x", "y"]
@btime simulate(// some other arguments//,
observables=observables, observable_names=observable_names)
The function simulate
calls another function that is supposed to check the validity of passed input arguments:
## in function simulate(...)
argument_check(//some other arguments//, observables, observable_names)
The definition of that function:
Function argument_check(// other arguments//
observables::Vector{<:Function},
observable_names::Vector{String}
)
// some exceptions
if size(observables)!= size(observable_names)
throw(DimensionMismatch("Number of observable names does not correspond to number of passed observables!\n"))
end
// some more exceptions
end
This exception is triggered when the macro @btime is used with simulate
.
Why does the macro mess with what happens in my function?