Skip to content

Commit 51a918d

Browse files
gustaphevchuravy
andauthored
Add plot capability (JuliaCI#194)
* Add plots recipes for single Trial or BenchmarkGroup of Trials Co-authored-by: Valentin Churavy <[email protected]>
1 parent b7a51bd commit 51a918d

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

BenchmarkPlots/Project.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name = "BenchmarkPlots"
2+
uuid = "ab8c0f59-4072-4e0d-8f91-a91e1495eb26"
3+
version = "0.1.0"
4+
5+
[deps]
6+
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
7+
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
8+
9+
[compat]
10+
BenchmarkTools = "1"
11+
RecipesBase = "1"

BenchmarkPlots/src/BenchmarkPlots.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module BenchmarkPlots
2+
using RecipesBase
3+
using BenchmarkTools: Trial, BenchmarkGroup
4+
5+
@recipe function f(::Type{Trial}, t::Trial)
6+
seriestype --> :violin
7+
legend --> false
8+
yguide --> "t / ns"
9+
xticks --> false
10+
t.times
11+
end
12+
13+
@recipe function f(g::BenchmarkGroup, keys=keys(g))
14+
legend --> false
15+
yguide --> "t / ns"
16+
for k in keys
17+
@series begin
18+
label --> string(k)
19+
xticks --> true
20+
[string(k)], g[k]
21+
end
22+
end
23+
end
24+
25+
end

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1111

1212
[compat]
1313
julia = "1"
14-
JSON = "0.18, 0.19, 0.20, 0.21"
14+
JSON = "0.18, 0.19, 0.20, 0.21"
1515

1616
[extras]
1717
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

docs/src/manual.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Manual
2-
32
BenchmarkTools was created to facilitate the following tasks:
43

54
1. Organize collections of benchmarks into manageable benchmark suites
@@ -896,6 +895,32 @@ julia> loadparams!(suite, BenchmarkTools.load("params.json")[1], :evals, :sample
896895

897896
Caching parameters in this manner leads to a far shorter turnaround time, and more importantly, much more consistent results.
898897

898+
## Visualizing benchmark results
899+
The `Trial` object can be visualized using the `BenchmarkPlots` package:
900+
901+
```julia
902+
using BenchmarkPlots, StatsPlots
903+
b = @benchmarkable lu(rand(10,10))
904+
t = run(b)
905+
906+
plot(t)
907+
```
908+
909+
This will show the timing results of the trial as a violin plot. You can use
910+
all the keyword arguments from `Plots.jl`, for instance `st=:box` or
911+
`yaxis=:log10`.
912+
913+
If a `BenchmarkGroup` contains (only) `Trial`s, its results can be visualized
914+
simply by
915+
916+
```julia
917+
using BenchmarkPlots, StatsPlots
918+
t = run(g)
919+
plot(t)
920+
```
921+
922+
This will display each `Trial` as a violin plot.
923+
899924
## Miscellaneous tips and info
900925

901926
- BenchmarkTools restricts the minimum measurable benchmark execution time to one picosecond.

0 commit comments

Comments
 (0)