BenchmarkTools.jl
BenchmarkTools.jl copied to clipboard
ERROR: DomainError with -43.0: log will only return a complex result if called with a complex argument. Try log(Complex(x)).
in BenchmarkTools v1.1.1 and v1.1.2 the following benchmark produces an error.
julia> @benchmark for i in 1:100 sin(x[i]) end setup = (x = rand(100)) evals = 1 samples = 100
BenchmarkTools.Trial: 100 samples with 1 evaluation.
Range (min … max): 836.000 ns … 10.789 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 1.006 μs ┊ GC (median): 0.00%
Time (mean ± σ): 1.109 μs ± 981.010 ns ┊ GC (mean ± σ): 0.00% ± 0.00%Error showing value of type BenchmarkTools.Trial:
ERROR: DomainError with -8.0:
log will only return a complex result if called with a complex argument. Try log(Complex(x)).
Stacktrace:
I also encountered this error in a different benchmark, which also used multiple samples.
It is also not hard to find the source of the error: The code that computes the bins for the histogram of the times assumes that the times are sorted, which is not the case.
When was this issue introduced into the code base?
When implementing the new display method, I noticed that the times were always sorted. I'm surprised to hear this isn't always the case? I tried running that benchmark and I didn't see any error.

I also ran into this issue, which occurred at times.