# Defining : name 'BenchmarkToools' - how?

**URL:** <https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428>\
**Category:** Optimization (Mathematical)\
**Created:** [November 1, 2020, 9:40pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428 "2020-11-01T21:40:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 9:40pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/1 "2020-11-01T21:40:42Z")

</div>

Hi,  
newbie trying to understand how to define the ‘BenchmarkToools’ ?  
I installed ‘BenchmarkToools’ with using/add Pkg.  
now in jupyter notebook : getting msg:  
NameError: name ‘BenchmarkToools’ is not defined  
So does one have to set a variable like b = BenchmarkToools(x) or how does this work ?  
Thanks

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [November 1, 2020, 9:54pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/2 "2020-11-01T21:54:34Z")

</div>

Is it simply that you are misspelling the name, with three ‘o’ characters instead of two? Try rerunning with  
`using BenchmarkTools`.

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 10:01pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/3 "2020-11-01T22:01:08Z")

</div>

Hi @John_Gibson,  
correct, it was misspeled in the above line - oops thanks -  
now entering BenchmarkTools, it just outputs BenchmarkTools…  
so, where to go from there to measure some script time exec ?

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 10:04pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/4 "2020-11-01T22:04:31Z")

</div>

I get results using @time …but not using @benchmark … 🤨

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [November 1, 2020, 10:13pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/5 "2020-11-01T22:13:13Z")

</div>

I’ll point you to the [Benchmarks manual](https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md) and suggest that you post minimal working examples of any issues you are having. This PSA explains how and why.  
[https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/81](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757/81)

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [November 1, 2020, 11:01pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/6 "2020-11-01T23:01:48Z")

</div>

```julia
julia> using BenchmarkTools

julia> @benchmark randn(1000)
BenchmarkTools.Trial: 
  memory estimate: 7.94 KiB
  allocs estimate: 1
  --------------
  minimum time: 2.196 μs (0.00% GC)
  median time: 2.470 μs (0.00% GC)
  mean time: 2.590 μs (3.68% GC)
  maximum time: 76.003 μs (92.82% GC)
  --------------
  samples: 10000
  evals/sample: 9

```

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 11:03pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/7 "2020-11-01T23:03:41Z")

</div>

oh, of course @John_Gibson , I was so into the basic course that I forgot to mention my code : … 🙈 🙊

```julia
a = rand(10^7)
sum(a)
@time sum(a)

```

I think I got it right now with the added line, thanks to the doc you’ve just provided me, Great thanks for that ! have a great end-of-Week-end ! 🤗

```julia
@benchmark sum(a) (had tried s/t else that was not working for sure)

```

its all working fine now…thanks guys

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 11:04pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/8 "2020-11-01T23:04:54Z")

</div>

I’ll test it with rand function too…good idea !

---

<div class="post-metadata">

**Author:** ![John\_Gibson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/john_gibson/32/5321_2.png) [@John\_Gibson](https://discourse.julialang.org/u/John_Gibson)\
**Post date:** [November 1, 2020, 11:09pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/9 "2020-11-01T23:09:10Z")

</div>

Glad to hear you are up and running!

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 11:10pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/10 "2020-11-01T23:10:09Z")

</div>

```julia

BenchmarkTools.Trial: 
  memory estimate: 7.94 KiB
  allocs estimate: 1
  --------------
  minimum time: 1.865 μs (0.00% GC)
  median time: 2.065 μs (0.00% GC)
  mean time: 2.892 μs (8.88% GC)
  maximum time: 227.362 μs (98.09% GC)
  --------------
  samples: 10000
  evals/sample: 10

```

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 1, 2020, 11:12pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/11 "2020-11-01T23:12:05Z")

</div>

just in the middle of the Parallel julia ac. course but hope to be able to use all Pc Cores for my future scripts… 🙃

---

<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:** [November 2, 2020, 8:37am UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/12 "2020-11-02T08:37:48Z")

</div>

Just to add that the closest equivalent to `time` in `BenchmarkTools` is `@btime`, which will just output the runtime and memory allocations.

---

<div class="post-metadata">

**Author:** ![teriiju](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/teriiju/32/19029_2.png) [@teriiju](https://discourse.julialang.org/u/teriiju)\
**Post date:** [November 2, 2020, 6:46pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/13 "2020-11-02T18:46:01Z")

</div>

Hi wisers…

- While with Julia Konsole 1

```julia

```

_ **returns 2 threads** _

…when restarting jupyter from Konsole2 after that

```julia
Threads.nthreads()

```

_ **still returns 1 thread.** _… 🙊

How does one have Jupyter to take this julia modif into account ?  
thanks

---

<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:** [November 2, 2020, 6:48pm UTC](https://discourse.julialang.org/t/defining-name-benchmarktoools-how/49428/14 "2020-11-02T18:48:10Z")

</div>

This is quite a different question from the one this thread is about - it’s usually preferable to ask separate questions to make things easier to find for future users.

In this case, someone already did start a thread about this specific question: [Enable multiple Cores for Jupyter Lab - #7 by Gaussia](https://discourse.julialang.org/t/enable-multiple-cores-for-jupyter-lab/18658/7)
