From fb208378610bd15ddd9d93403f25199622e66ce3 Mon Sep 17 00:00:00 2001 From: yashcodes <747747747yash> Date: Wed, 27 Feb 2019 07:22:49 +0530 Subject: [PATCH] Adding benchmarks folder --- benchmark/benchmarks.jl | 28 ++++++++++++++++++++++++++++ benchmark/examples.jl | 33 +++++++++++++++++++++++++++++++++ src/HeapedVectors.jl | 3 +-- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 benchmark/benchmarks.jl create mode 100644 benchmark/examples.jl diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl new file mode 100644 index 0000000..1a05fef --- /dev/null +++ b/benchmark/benchmarks.jl @@ -0,0 +1,28 @@ +include("examples.jl") +using .OneDimExamples, .TwoDimExamples + +using BenchmarkTools +using IntervalArithmetic +using IntervalOptimisation + +const SUITE = BenchmarkGroup() + + +S = SUITE["One dimensional function"] = BenchmarkGroup() + +for func in (OneDimExamples.func1, OneDimExamples.func2, OneDimExamples.func3) + s = S[func.title] = BenchmarkGroup() + for Structure in (HeapedVector, SortedVector) + s[string(Structure)] = @benchmarkable minimise($(func.func), $(func.region), structure = $Structure) + end +end + + +S = SUITE["Two dimensional function"] = BenchmarkGroup() + +for func in (TwoDimExamples.Rosenbrock) + s = S[func.title] = BenchmarkGroup() + for Structure in (HeapedVector, SortedVector) + s[string(Structure)] = @benchmarkable minimise($(func.func), $(func.region), structure = $Structure ) + end +end diff --git a/benchmark/examples.jl b/benchmark/examples.jl new file mode 100644 index 0000000..161f502 --- /dev/null +++ b/benchmark/examples.jl @@ -0,0 +1,33 @@ +module Working_function +using IntervalArithmetic + +struct Working_func{F<:Function, reg<:Union{Interval, IntervalBox}} + title::String + region::reg + func::F +end + +end + + +module OneDimExamples + +using IntervalArithmetic, IntervalOptimisation + +import ..Working_function:Working_func +func1 = Working_func("Quadratic equation", (-1..2), x->x*(x-1) ) +func2 = Working_func("Cubic equation", (-1..4), x->(x-2)^3-5x ) +func3 = Working_func("Quartic equation", (-4..6), x->(x-6)*(x+4)*(7x^2+10x+24) ) + +end + + + +module TwoDimExamples + +using IntervalArithmetic, IntervalOptimisation + +import ..Working_function:Working_func +rosenbrock(xx) = ( (x, y) = xx; 100*(y - x)^2 + (x - 1)^2 ) +Rosenbrock = Working_func("Rosenbrock function", IntervalBox(-5..5, 2), rosenbrock) +end diff --git a/src/HeapedVectors.jl b/src/HeapedVectors.jl index 98f2092..83bf0dc 100644 --- a/src/HeapedVectors.jl +++ b/src/HeapedVectors.jl @@ -98,8 +98,7 @@ function filter_elements!(A::HeapedVector{T}, x::T) where{T} if length(A.data) == 0 return A end - - heaping(A.data, A.by) + heaping(A.data, A.by) return A end