Chairmarks.jl icon indicating copy to clipboard operation
Chairmarks.jl copied to clipboard

How to setup for function with multiple arguments?

Open nathanrboyer opened this issue 4 months ago • 2 comments

I am writing a PR to Modern Julia Workflows to suggest Chairmarks over BenchmarkTools. Their current text has this BenchmarkTools.jl example that I don't know how to do with Chairmarks. I couldn't find any examples like this in the documentation.

my_matmul(A, b) = A * b;
@btime my_matmul(A, b) setup=(
    A = rand(1000, 1000); # use semi-colons between setup lines
    b = rand(1000)
);

nathanrboyer avatar Aug 26 '25 20:08 nathanrboyer

Thanks for asking!

@b rand(1000, 1000),rand(1000) my_matmul(_...)

The setup block can only return a single value, but that value may be a tuple.

I'll leave this issue open until I add an example to the docs which showcases this.

LilithHafner avatar Aug 27 '25 12:08 LilithHafner

I guess a NamedTuple could also be useful for clarity.

@be (A=rand(1000,1000), b=rand(1000)) my_matmul(_.A, _.b)

Here's the MJW PR in case you're interested: https://github.com/modernjuliaworkflows/modernjuliaworkflows.github.io/pull/138

nathanrboyer avatar Aug 27 '25 14:08 nathanrboyer