Benchmark macro doesn't display anything in VSCode

I am new to Julia and very exited to get into it. As part of learning, I am trying to use the @benchmark macro to see how I can optimize different aspects of Julia code, as well as the impact of for example = vs .=, etc. However, when using it in VSCode it doesn’t display anything. If it’s relevant, I am running Julia on the VSCode Terminal

Thank you in advance!

Hi @Nandophi! Can you maybe post the full code you used in your Julia session?

1 Like

It you are coming from another language make sure you don’t put a “;” at the end of the line. Also you can use ‘@btime’ which actually prints rather than relying on display


Sure! Here it is, thank you

using BenchmarkTools
using FFTW
import Plots

function timefft()
N = 2^9
x = rand(ComplexF64, N)
for i = 1:100
x .= rand(ComplexF64, N)


@time timefft()
@benchmark timefft()

@ndinsmore ,okay thank you for the tip!

Just so you know that benchmark is going to be polluted by the time of rand

It seems to work on my end, can you maybe send a screenshot of what your window looks like after executing the last line?

@gdalle I would show it, but the only that the only thing that appears in my VSCode Terminal is my path when I execute, for example
@benchmark sin(3)

Are you executing code lines from a file, jupyter-style, or directly from the REPL?

@gdalle , I’m running code from a file, using VSCode as my text editor or IDE

In the VSCode Julia extension settings there are options to toggle on whether you want outputs from such a process to be displayed in the REPL, maybe that’s it?

If your purpose is to time the execution of fft, then this is not the right way to do it. There’s no need for a loop, since @benchmark will run the code many times for you. Just do this:

x = rand(ComplexF64, N) 
@benchmark fft($x)

That’s all you need.

@gdalle , I didn’t know that. Let me see how I can change the configuration, thank you!

You can try to force the output:

bm = @benchmark timefft()
@show bm