# BenchmarkTools @benchmark beautiful histogram reuse

**URL:** https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053
**Category:** General Usage
**Tags:** plotting, unicodeplots, histogram
**Created:** [January 23, 2022, 5:38am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053 "2022-01-23T05:38:29Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [January 23, 2022, 5:38am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/1 "2022-01-23T05:38:29Z")

</div>

Dear Julianners,

I saw the beautiful histogram unicode plots of `BenchmarkTools` of `@benchmark`

```julia
BenchmarkTools.Trial:
 10000 samples with 968 evaulations took a median time of 90.902 ns (0.00% GC)
 Time (mean ± σ): 94.936 ns ± 47.797 ns (GC: 2.78% ± 5.03%)
 Range (min … max): 77.655 ns … 954.823 ns (GC: 0.00% … 87.94%)

          ▁▃▅▆▇█▇▆▅▂▁                                          
  ▂▂▃▃▄▅▆▇███████████▇▆▄▄▃▃▂▂▂▂▂▂▂▂▂▂▂▁▂▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂
  77.7 ns Histogram: frequency by time 137 ns

```

How can I use their histogram plotting?

Bests,  
Marcell

---

<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: [January 23, 2022, 5:43am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/2 "2022-01-23T05:43:55Z")

</div>

Could you clarify your question? What do you mean by “use their histogram”?

---

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [January 23, 2022, 7:10am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/3 "2022-01-23T07:10:51Z")

</div>

Yes, or modify it a little.  
I mean by using it, to do histogram plotting with their UI using my dataset, to be precise.

---

<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: [January 23, 2022, 7:57am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/4 "2022-01-23T07:57:43Z")

</div>

So you want to plot a histogram of your own data (just any data, not benchmarking results) using the histogram from BenchmarkTools?

The relevant code is here:

[https://github.com/JuliaCI/BenchmarkTools.jl/blob/4da9aaf5ccb9d8ab475566c1690b422e253b7f61/src/trials.jl#L293](https://github.com/JuliaCI/BenchmarkTools.jl/blob/4da9aaf5ccb9d8ab475566c1690b422e253b7f61/src/trials.jl#L293)

Although I probably would just use `UnicodePlots` to create plots in the terminal (either standalone or as a `Plots` backend):

```julia
julia> using UnicodePlots

julia> histogram(randn(10_000), xlabel = "Something", ylabel = "Something else")
                               ┌ ┐ 
                  [-5.0, -4.0) ┤▏ 1                                       
                  [-4.0, -3.0) ┤▎ 19                                      
                  [-3.0, -2.0) ┤██▎ 217                                   
                  [-2.0, -1.0) ┤█████████████▎ 1342                       
   Something else [-1.0, 0.0) ┤██████████████████████████████████ 3454  
                  [ 0.0, 1.0) ┤█████████████████████████████████▏ 3359   
                  [ 1.0, 2.0) ┤█████████████▋ 1385                       
                  [ 2.0, 3.0) ┤██▎ 212                                   
                  [ 3.0, 4.0) ┤▎ 10                                      
                  [ 4.0, 5.0) ┤▏ 1                                       
                               └ ┘ 
                                                Something

```

---

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [January 23, 2022, 7:59am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/5 "2022-01-23T07:59:59Z")

</div>

Sorry, the key is to produce similar output. I think I forgot to mention that.  
So basically I need the a vertical histogram that is used by BenchmarkTools.

---

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [January 23, 2022, 8:01am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/6 "2022-01-23T08:01:42Z")

</div>

Ok I think I see.

[https://github.com/JuliaCI/BenchmarkTools.jl/blob/4da9aaf5ccb9d8ab475566c1690b422e253b7f61/src/trials.jl#L341](https://github.com/JuliaCI/BenchmarkTools.jl/blob/4da9aaf5ccb9d8ab475566c1690b422e253b7f61/src/trials.jl#L341)  
I think I will copy this.

---

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [January 30, 2022, 11:53am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/7 "2022-01-30T11:53:08Z")

</div>

Hey,

I had to modify it a little bit so I created a vertical unicode histogram plot again  
[https://github.com/Cvikli/HistogramUnicode.jl](https://github.com/Cvikli/HistogramUnicode.jl)

I hope it is useful for the community by time…

---

<div class="post-metadata">

### Author: ![zsz00](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zsz00/32/6314_2.png) [@zsz00](https://discourse.julialang.org/u/zsz00)
#### Post date: [January 30, 2022, 1:52pm UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/8 "2022-01-30T13:52:01Z")

</div>

why not add this vertical unicode histogram plot to UnicodePlots.jl ?

---

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [February 1, 2022, 6:27am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/9 "2022-02-01T06:27:16Z")

</div>

How to add it to a repository like that?

---

<div class="post-metadata">

### Author: ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)
#### Post date: [February 15, 2022, 11:47pm UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/10 "2022-02-15T23:47:59Z")

</div>

You’d open an issue in the UnicodePlots repo, and then point them to your implementation.  
Then you can iterate with the authors of UnicodePlots on how to best integrate your code into the existing repo.

---

<div class="post-metadata">

### Author: ![jstrube](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jstrube/32/525_2.png) [@jstrube](https://discourse.julialang.org/u/jstrube)
#### Post date: [February 15, 2022, 11:51pm UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/11 "2022-02-15T23:51:21Z")

</div>

Btw, I’ve also just looked for a way to make a vertical hist in UnicodePlots. Thanks for making your code available!  
You could also think about just plotting the outline.  
Maybe it depends on the terminal whether or not this is easy to see…

---

<div class="post-metadata">

### Author: ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)
#### Post date: [February 16, 2022, 8:54am UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/12 "2022-02-16T08:54:33Z")

</div>

If you are willing, you can contribute to the PR opened by @Marcell_Havlik at [https://github.com/JuliaPlots/UnicodePlots.jl/pull/221](https://github.com/JuliaPlots/UnicodePlots.jl/pull/221), since it will need more rework before integration.

---

<div class="post-metadata">

### Author: ![Marcell\_Havlik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcell_havlik/32/37424_2.png) [@Marcell\_Havlik](https://discourse.julialang.org/u/Marcell_Havlik)
#### Post date: [March 7, 2022, 8:59pm UTC](https://discourse.julialang.org/t/benchmarktools-benchmark-beautiful-histogram-reuse/75053/13 "2022-03-07T20:59:36Z")

</div>

Hey,  
I just wanted to note if someone wants to take the effort to merge this repo [UnicodePlotsSimple.jl](https://github.com/Cvikli/UnicodePlotsSimple.jl) into the main [JuliaPlots/UnicodePlots.jl](https://github.com/JuliaPlots/UnicodePlots.jl)  
[Pull Request #221 - JuliaPlots/UnicodePlots.jl GitHub](https://github.com/JuliaPlots/UnicodePlots.jl/pull/221)
