Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update benchmarks.jl #156

Merged
merged 3 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions benchmark/REQUIRE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BenchmarkTools 0.3.1
PkgBenchmark 0.1.1
46 changes: 25 additions & 21 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,49 @@
- results = benchmarkpkg("IntervalArithmetic")
- showall(results)

- results = judge("IntervalArithmetic", "v0.9.1") # compare current version to that tag
To compare the current version with a given release use `judge`:

- results = judge("IntervalArithmetic", tag)
- showall(results)
=#

To export the benchmark results to a markdown file, do:

using IntervalArithmetic
- export_markdown("results.md", results)
=#

@benchgroup "Constructors" begin
@bench "Interval" Interval(1, 2)
end
using BenchmarkTools, IntervalArithmetic

@benchgroup "@interval" begin
const SUITE = BenchmarkGroup() # parent BenchmarkGroup to contain our suite

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

@benchgroup "Arithmetic" begin
S = SUITE["Intervals"] = BenchmarkGroup()
S["@interval"] = @benchmarkable @interval(0.1)
S["pi"] = @benchmarkable @interval(pi)
S["expression"] = @benchmarkable @interval(sin(0.1) + cos(0.2))

S = SUITE["Arithmetic"] = BenchmarkGroup()
begin
a = Interval(1, 2)
b = Interval(3, 4)

for op in (+, -, *, /)
@bench string(op) $(op)($a, $b)
S[string(op)] = @benchmarkable $(op)($a, $b)
end
end

@benchgroup "Elementary functions" begin
S = SUITE["Elementary functions"] = BenchmarkGroup()
begin
for op in (exp, log, sin, tan)
@bench string(op) $(op)($a)
S[string(op)] = @benchmarkable $(op)($a)
end
end

@benchgroup "Sum" begin

S = SUITE["Sum"] = BenchmarkGroup()
begin
sum1(N) = sum(Interval(i, i+1) for i in 1:N)
sum2(N) = (one = Interval(1.0); sum(one / (i^2) for i in 1:N) )

@bench "Sum1" sum1(1000)
@bench "Sum2" sum2(1000)
sum2(N) = (one = Interval(1.0); sum(one / (i^2) for i in 1:N))
S["Sum1"] = @benchmarkable sum1(1000)
S["Sum2"] = @benchmarkable sum2(1000)
end