BenchmarkTools @btime breaks my function arguments

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// 
// some exceptions

    if size(observables)!= size(observable_names)
        throw(DimensionMismatch("Number of observable names does not correspond to number of passed observables!\n"))

// some more exceptions


This exception is triggered when the macro @btime is used with simulate.
Why does the macro mess with what happens in my function?

One thing @btime does is run the call repeatedly, so does simulate push any elements to observables or observable_names, what do they look like after 1 simulate call?

1 Like

it does change them towards the end for some print out routine. That fixes it,cheers!