# BenchmarkTools.jl and VScode

**URL:** <https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [February 26, 2024, 4:28pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791 "2024-02-26T16:28:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heng\_Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heng_zhang/32/207300_2.png) [@Heng\_Zhang](https://discourse.julialang.org/u/Heng_Zhang)\
**Post date:** [February 26, 2024, 4:28pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/1 "2024-02-26T16:28:47Z")

</div>

‘’‘julia  
using BenchmarkTools  
@benchmark sort(data) setup=(data=rand(10))  
‘’’  
When I ran these code in Vs-code, errors as below:  
BenchmarkTools.Trial: 10000 samples with 1000 evaluations.  
ERROR: MethodError: no method matching median(::Vector{Float64})

Closest candidates are:  
median(::AbstractVector{T} where T\<:Real, ::AbstractWeights)  
@ StatsBase C:\Users\zzzz.julia\packages\StatsBase\XgjIN\src\weights.jl:782  
median(::BenchmarkTools.Trial)  
@ BenchmarkTools C:\Users\zzzz.julia\packages\BenchmarkTools\QAv7m\src\trials.jl:129  
median(::Distributions.Kolmogorov)  
@ Distributions C:\Users\zzzz.julia\packages\Distributions\km0AH\src\univariate\continuous\kolmogorov.jl:27  
…  
Is there any issue in my BenchmarkTools package? Its version is 1.4.0

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 26, 2024, 5:00pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/2 "2024-02-26T17:00:15Z")

</div>

Works fine for me - have you somehow managed to shadow `median`? The method `median(::Vector{Float64})` does exist unless you’ve somehow shadowed it.

---

<div class="post-metadata">

**Author:** ![Heng\_Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heng_zhang/32/207300_2.png) [@Heng\_Zhang](https://discourse.julialang.org/u/Heng_Zhang)\
**Post date:** [February 26, 2024, 5:20pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/3 "2024-02-26T17:20:50Z")

</div>

Maybe, my friend also could run it successfully. How to confirm if I shadowed `median(::Vector{Float64})` , and if it is true, how to fix it?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 26, 2024, 6:20pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/4 "2024-02-26T18:20:46Z")

</div>

Do you have `median =... ` somewhere in your code?

---

<div class="post-metadata">

**Author:** ![Heng\_Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heng_zhang/32/207300_2.png) [@Heng\_Zhang](https://discourse.julialang.org/u/Heng_Zhang)\
**Post date:** [February 26, 2024, 8:05pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/5 "2024-02-26T20:05:59Z")

</div>

> [@Heng\_Zhang](#):
>
> ‘’‘julia  
> using BenchmarkTools  
> @benchmark sort(data) setup=(data=rand(10))  
> ‘’’

No, only below two lines of code:  
using BenchmarkTools  
@benchmark sort(data) setup=(data=rand(10))

---

<div class="post-metadata">

**Author:** ![Zentrik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zentrik/32/35409_2.png) [@Zentrik](https://discourse.julialang.org/u/Zentrik)\
**Post date:** [February 26, 2024, 8:50pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/6 "2024-02-26T20:50:03Z")

</div>

Try restarting the REPL (either click the bin icon on your REPL and start a new one, or you can use the restart repl command (ctrl-shift-p then searching restart repl might work)). Then run those two lines.

If it still doesn’t work please provide the complete error.

---

<div class="post-metadata">

**Author:** ![Heng\_Zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heng_zhang/32/207300_2.png) [@Heng\_Zhang](https://discourse.julialang.org/u/Heng_Zhang)\
**Post date:** [February 27, 2024, 3:57pm UTC](https://discourse.julialang.org/t/benchmarktools-jl-and-vscode/110791/7 "2024-02-27T15:57:59Z")

</div>

Thank you for your help. 😄
