Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display fails with only one sample #261

Closed
LilithHafner opened this issue Sep 25, 2021 · 1 comment
Closed

Display fails with only one sample #261

LilithHafner opened this issue Sep 25, 2021 · 1 comment

Comments

@LilithHafner
Copy link
Contributor

I ran into this issue when benchmarking a long running function in the REPL where display is automatic:

julia> @benchmark long_running()

It can be easily replicated with

@benchmark sleep(5)

or

@benchmark 1+1 samples=1

To get a nicer error message, I displayed explicitly with this:

julia> display(@benchmark sleep(5))
BechmarkTools.Trial: 1 samples with 1 evaluations.
 Range (min … max):  5.004 s … 5.004 s  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     5.004 s            ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.004 s ±   NaN s  ┊ GC (mean ± σ):  0.00% ±  NaN%ERROR: BoundsError: attempt to access 1-element Vector{Float64} at index [0]
Stacktrace:
 [1] getindex
   @ ./array.jl:801 [inlined]
 [2] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, t::BenchmarkTools.Trial)
   @ BenchmarkTools ~/.julia/packages/BenchmarkTools/Rqvks/src/trials.jl:441
 [3] (::REPL.var"#38#39"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
   @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:220
 [4] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
   @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:462
 [5] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
   @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:213
 [6] display(d::REPL.REPLDisplay, x::Any)
   @ REPL /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:225
 [7] display(x::Any)
   @ Base.Multimedia ./multimedia.jl:328
 [8] top-level scope
   @ ~/.julia/packages/BenchmarkTools/Rqvks/src/execution.jl:389

I'd rather get this:

julia> display(@benchmark sleep(5))
BechmarkTools.Trial: 1 samples with 1 evaluations.
 Range (min … max):  5.004 s … 5.004 s  ┊ GC (min … max): 0.00% … 0.00%
 Time  (median):     5.004 s            ┊ GC (median):    0.00%
 Time  (mean ± σ):   5.004 s ±   NaN s  ┊ GC (mean ± σ):  0.00% ±  NaN%
@LilithHafner
Copy link
Contributor Author

On BenchmarkTools v1.3.1

julia> @benchmark sleep(5)
BenchmarkTools.Trial: 1 sample with 1 evaluation.
 Single result which took 5.002 s (0.00% GC) to evaluate,
 with a memory estimate of 144 bytes, over 5 allocations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant