Skip to content

Commit e6e0d0d

Browse files
mforetsdpsanders
authored andcommitted
Update benchmarks.jl (#156)
* Update benchmarks.jl update benchmarks to use BenchmarkGroup() syntax * add REQUIRE to benchmarks * update benchmarks instructions
1 parent 6dce3a9 commit e6e0d0d

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

benchmark/REQUIRE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
BenchmarkTools 0.3.1
2+
PkgBenchmark 0.1.1

benchmark/benchmarks.jl

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,49 @@
66
- results = benchmarkpkg("IntervalArithmetic")
77
- showall(results)
88
9-
- results = judge("IntervalArithmetic", "v0.9.1") # compare current version to that tag
9+
To compare the current version with a given release use `judge`:
10+
11+
- results = judge("IntervalArithmetic", tag)
1012
- showall(results)
11-
=#
1213
14+
To export the benchmark results to a markdown file, do:
1315
14-
using IntervalArithmetic
16+
- export_markdown("results.md", results)
17+
=#
1518

16-
@benchgroup "Constructors" begin
17-
@bench "Interval" Interval(1, 2)
18-
end
19+
using BenchmarkTools, IntervalArithmetic
1920

20-
@benchgroup "@interval" begin
21+
const SUITE = BenchmarkGroup() # parent BenchmarkGroup to contain our suite
2122

22-
@bench "@interval" @interval(0.1)
23-
@bench "pi" @interval(pi)
24-
@bench "expression" @interval(sin(0.1) + cos(0.2))
25-
end
23+
S = SUITE["Constructors"] = BenchmarkGroup()
24+
S["Interval"] = @benchmarkable Interval(1, 2)
2625

27-
@benchgroup "Arithmetic" begin
26+
S = SUITE["Intervals"] = BenchmarkGroup()
27+
S["@interval"] = @benchmarkable @interval(0.1)
28+
S["pi"] = @benchmarkable @interval(pi)
29+
S["expression"] = @benchmarkable @interval(sin(0.1) + cos(0.2))
2830

31+
S = SUITE["Arithmetic"] = BenchmarkGroup()
32+
begin
2933
a = Interval(1, 2)
3034
b = Interval(3, 4)
3135

3236
for op in (+, -, *, /)
33-
@bench string(op) $(op)($a, $b)
37+
S[string(op)] = @benchmarkable $(op)($a, $b)
3438
end
3539
end
3640

37-
@benchgroup "Elementary functions" begin
41+
S = SUITE["Elementary functions"] = BenchmarkGroup()
42+
begin
3843
for op in (exp, log, sin, tan)
39-
@bench string(op) $(op)($a)
44+
S[string(op)] = @benchmarkable $(op)($a)
4045
end
4146
end
4247

43-
@benchgroup "Sum" begin
44-
48+
S = SUITE["Sum"] = BenchmarkGroup()
49+
begin
4550
sum1(N) = sum(Interval(i, i+1) for i in 1:N)
46-
sum2(N) = (one = Interval(1.0); sum(one / (i^2) for i in 1:N) )
47-
48-
@bench "Sum1" sum1(1000)
49-
@bench "Sum2" sum2(1000)
51+
sum2(N) = (one = Interval(1.0); sum(one / (i^2) for i in 1:N))
52+
S["Sum1"] = @benchmarkable sum1(1000)
53+
S["Sum2"] = @benchmarkable sum2(1000)
5054
end

0 commit comments

Comments
 (0)