From e6e0d0de4098381336f68e2f3fc414f8e3ad97bb Mon Sep 17 00:00:00 2001 From: Marcelo Forets Date: Fri, 29 Jun 2018 11:25:47 -0300 Subject: [PATCH] Update benchmarks.jl (#156) * Update benchmarks.jl update benchmarks to use BenchmarkGroup() syntax * add REQUIRE to benchmarks * update benchmarks instructions --- benchmark/REQUIRE | 2 ++ benchmark/benchmarks.jl | 46 ++++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 benchmark/REQUIRE diff --git a/benchmark/REQUIRE b/benchmark/REQUIRE new file mode 100644 index 000000000..40e1c265c --- /dev/null +++ b/benchmark/REQUIRE @@ -0,0 +1,2 @@ +BenchmarkTools 0.3.1 +PkgBenchmark 0.1.1 \ No newline at end of file diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index eff576c60..80718e54a 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -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