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

No output when running @benchmark from script file #281

Open
chw90 opened this issue Apr 20, 2022 · 3 comments
Open

No output when running @benchmark from script file #281

chw90 opened this issue Apr 20, 2022 · 3 comments

Comments

@chw90
Copy link

chw90 commented Apr 20, 2022

Is there a way to define benchmarks using @benchmark in a script file script.jl and run them via $ julia script.jl?

From the runtime of the Julia command, seems that the benchmarks are actually run, but theres nothing printed to my shell.

@danielsoutar
Copy link

Is there a way to define benchmarks using @benchmark in a script file script.jl and run them via $ julia script.jl?

From the runtime of the Julia command, seems that the benchmarks are actually run, but theres nothing printed to my shell.

I second this. It'd be fantastic if there was a way of being able to get the wonderful visualisations of the REPL in an automated fashion with a script. I'm interested in tracking performance in my codebase and one-off benchmarks, while still useful, are far more limited than if I were to have scripts that could automate the process for me.

@Sean1708
Copy link

Sean1708 commented Jun 7, 2022

As far as I can tell @benchmark isn't responsible for doing any printing whatsoever, and it shouldn't be responsible for that either IMO. You get a pretty output in the REPL because the REPL implicitly calls show on result of the the last expression. To get that output from a script you can either use

display(@benchmark function_to_be_benchmarked())

if you just want the output to go to whatever the default display is, or

show(stdout, "text/plain", @benchmark function_to_be_benchmarked())

if you specifically want it to go to stdout.

@gdalle
Copy link
Collaborator

gdalle commented Jun 13, 2023

This option should probably be documented

Also related: #1

@gdalle gdalle added this to the v2.0 milestone Sep 18, 2023
@gdalle gdalle removed this from the v2.0 milestone Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants