Reputation: 698
function1(args; kwargs)
and function2(args; kwargs)
are two functions that, given the same input, return the same output. I would like to check that function1
is faster than function2
. Both of these functions take a very long time to run (10 minutes). I tried using @btime
but this seems to take ages. My guess is that it is running the function thousands of times. I don't care too much about how precise the average is, so how can I benchmark the functions with just 1 or 2 runs?
Upvotes: 2
Views: 289
Reputation: 13800
@btime
is largely there to take care of two issues in benchmarking: compilation overhead and random noise caused by other processes on your system which may lead to the function running slower for reasons unrelated to the actual machine code being executed.
In your case it seems that neither of these are particularly worrying, simply because the runtime of the function is so long. You can take care of the compilation overhead by simply running both functions once before timing them, and random system noise will likely even out across the long runtime of your functions.
If you do want to use BenchmarkTools look at the samples
and evals
keywords to @benchmark
described in the manual here: https://juliaci.github.io/BenchmarkTools.jl/stable/manual/#Benchmark-Parameters
Upvotes: 2