# Benchmark macro doesn't display anything in VSCode

**URL:** <https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 6, 2023, 12:59am UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145 "2023-04-06T00:59:46Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nandophi](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@Nandophi](https://discourse.julialang.org/u/Nandophi)\
**Post date:** [April 6, 2023, 12:59am UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/1 "2023-04-06T00:59:46Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [April 6, 2023, 6:44am UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/2 "2023-04-06T06:44:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ndinsmore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndinsmore/32/7433_2.png) [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Post date:** [April 6, 2023, 11:48am UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/3 "2023-04-06T11:48:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nandophi](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@Nandophi](https://discourse.julialang.org/u/Nandophi)\
**Post date:** [April 6, 2023, 3:29pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/4 "2023-04-06T15:29:41Z")

</div>

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)  
fft(x)  
end  
end

timefft()

@time timefft()  
println()  
@benchmark timefft()

---

<div class="post-metadata">

**Author:** ![Nandophi](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@Nandophi](https://discourse.julialang.org/u/Nandophi)\
**Post date:** [April 6, 2023, 3:36pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/5 "2023-04-06T15:36:19Z")

</div>

@ndinsmore ,okay thank you for the tip!

---

<div class="post-metadata">

**Author:** ![ndinsmore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ndinsmore/32/7433_2.png) [@ndinsmore](https://discourse.julialang.org/u/ndinsmore)\
**Post date:** [April 6, 2023, 4:55pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/6 "2023-04-06T16:55:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [April 6, 2023, 8:19pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/7 "2023-04-06T20:19:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nandophi](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@Nandophi](https://discourse.julialang.org/u/Nandophi)\
**Post date:** [April 6, 2023, 8:43pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/8 "2023-04-06T20:43:42Z")

</div>

@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)

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [April 6, 2023, 9:36pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/9 "2023-04-06T21:36:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Nandophi](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@Nandophi](https://discourse.julialang.org/u/Nandophi)\
**Post date:** [April 7, 2023, 4:03pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/10 "2023-04-07T16:03:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [April 7, 2023, 5:40pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/11 "2023-04-07T17:40:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [April 7, 2023, 5:57pm UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/12 "2023-04-07T17:57:40Z")

</div>

> [@Nandophi](#):
>
> for i = 1:100  
> x .= rand(ComplexF64, N)  
> fft(x)  
> end

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:

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

```

That’s all you need.

---

<div class="post-metadata">

**Author:** ![Nandophi](https://avatars.discourse-cdn.com/v4/letter/n/51bf81/32.png) [@Nandophi](https://discourse.julialang.org/u/Nandophi)\
**Post date:** [April 8, 2023, 2:47am UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/13 "2023-04-08T02:47:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)\
**Post date:** [April 8, 2023, 6:00am UTC](https://discourse.julialang.org/t/benchmark-macro-doesnt-display-anything-in-vscode/97145/14 "2023-04-08T06:00:37Z")

</div>

You can try to force the output:

```julia
bm = @benchmark timefft()
@show bm

```
