Skip to content

Commit c9409e2

Browse files
authored
Cleanup benchmarks (#1937)
* Re-organise benchmarks * Delete MicroBenchmarks.yml * Update README.md
1 parent f61bb69 commit c9409e2

File tree

12 files changed

+20
-170
lines changed

12 files changed

+20
-170
lines changed

.github/workflows/MicroBenchmarks.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

benchmarks/BenchmarkHelper.jl

Lines changed: 0 additions & 43 deletions
This file was deleted.

benchmarks/README.md

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,18 @@
1-
# MicroBenchmarks for Turing.jl
1+
# Benchmarks for Turing.jl
22

33
## Write a benchmark
44

55
Generally, you can run any code in a benchmark. We use package
66
`BenchmarkTools.jl` to organize our benchmarks, and
7-
`BenchmarkHelper.BenchmarkSuite` is the root benchmark group, so you
7+
`BenchmarkSuite` is the root benchmark group, so you
88
can write a benchmark like this:
99

1010
```julia
11-
using Turing, BenchmarkHelper, BenchmarkTools
11+
using Turing, BenchmarkTools
1212

13-
BenchmarkSuite["dummy"] = BenchmarkGroup(["tag1", "tag2"])
13+
BenchmarkSuite["example_benchmark"] = BenchmarkGroup(["tag1", "tag2"])
1414

15-
BenchmarkSuite["dummy"]["benchmark_1"] = @benchmarkable a_time_consuming_computing()
15+
BenchmarkSuite["example_benchmark"]["benchmark_1"] = @benchmarkable a_time_consuming_computing()
1616
```
17-
More details can be found in the documents of `BenchmarkTools.jl`.
18-
19-
After its run, the results will be saved under the directory
20-
`benchmarks/output/`.
21-
22-
## Run on Github
2317

24-
All benchmarks under this directory can run on Github, triggered by
25-
commenting on a Pull Request (a.k.a Code Review Comment).
26-
27-
You must **@BayesBot** and include a command in pattern
28-
`runbenchmarks(benchamrk_tags, vs=branch)` in the comment text to
29-
specify the branches on which the benchmarks will run and trigger the
30-
benchmarks. This command pattern is borrowed from `Nanosoldier.jl`,
31-
please find more detail from [its
32-
documents](https://github.com/TuringLang/Nanosoldier.jl/blob/turing/README.md#trigger-syntax). Here
33-
is an examples:
34-
35-
```
36-
@BayesBot `runbenchmarks(ALL, vs=":master")`
37-
```
38-
39-
After these triggered benchmarks finish, the reports will be committed
40-
to
41-
[TuringLang/BenchmarkReports](https://github.com/TuringLang/BenchmarkReports),
42-
then a reply comment contains the reports link will be made on the
43-
original pull request.
44-
45-
### Notes
46-
47-
- Put a Regex pattern to the `EXCLUDES` array in
48-
`benchmarks/config.toml` to exclude paricular benchmark files
18+
More details can be found in the documents of `BenchmarkTools.jl`.

benchmarks/benchmarks.jl renamed to benchmarks/benchmarks_suite.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
using Turing, BenchmarkTools, BenchmarkHelper
1+
using Turing, BenchmarkTools
22
using LinearAlgebra
33

4-
## Dummny benchmarks
4+
const BenchmarkSuite = BenchmarkTools.BenchmarkGroup()
55

6-
BenchmarkSuite["dummy"] = BenchmarkGroup(["dummy"])
6+
#
7+
# Add models to benchmarks
8+
#
9+
10+
include("models/hlr.jl")
11+
include("models/lr.jl")
12+
include("models/sv_nuts.jl")
13+
14+
# constrained
15+
BenchmarkSuite["constrained"] = BenchmarkGroup(["constrained"])
716

817
data = [0, 1, 0, 1, 1, 1, 1, 1, 1, 1]
918

@@ -17,7 +26,7 @@ data = [0, 1, 0, 1, 1, 1, 1, 1, 1, 1]
1726
end
1827

1928

20-
BenchmarkSuite["dummy"]["dummy"] = @benchmarkable sample($(constrained_test(data)), $(HMC(0.01, 2)), 2000)
29+
BenchmarkSuite["constrained"]["constrained"] = @benchmarkable sample($(constrained_test(data)), $(HMC(0.01, 2)), 2000)
2130

2231

2332
## gdemo
@@ -35,9 +44,8 @@ end
3544
BenchmarkSuite["gdemo"]["hmc"] = @benchmarkable sample($(gdemo(1.5, 2.0)), $(HMC(0.01, 2)), 2000)
3645

3746

38-
##
47+
3948
## MvNormal
40-
##
4149

4250
BenchmarkSuite["mnormal"] = BenchmarkGroup(["mnormal"])
4351

benchmarks/config.toml

Lines changed: 0 additions & 7 deletions
This file was deleted.

benchmarks/nuts/hlr.jl renamed to benchmarks/models/hlr.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Turing
22
using LinearAlgebra
33

4-
using BenchmarkHelper
5-
64
include("lr_helper.jl")
75

86
if !haskey(BenchmarkSuite, "nuts")

benchmarks/nuts/lr.jl renamed to benchmarks/models/lr.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using Turing
22
using LinearAlgebra
33

4-
using BenchmarkHelper
5-
64
include("lr_helper.jl")
75

86
if !haskey(BenchmarkSuite, "nuts")
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)