From e8125488130fe08dd6e044024f3eaaa9d9596e89 Mon Sep 17 00:00:00 2001 From: Eeshan Gupta Date: Tue, 15 May 2018 15:05:16 +0530 Subject: [PATCH] Add benchmark script --- perf/linear_eq.jl | 30 ++++++++++++++++++++++++++++++ src/benchmark.jl | 17 ----------------- 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 perf/linear_eq.jl delete mode 100644 src/benchmark.jl diff --git a/perf/linear_eq.jl b/perf/linear_eq.jl new file mode 100644 index 00000000..a5c32314 --- /dev/null +++ b/perf/linear_eq.jl @@ -0,0 +1,30 @@ +using IntervalArithmetic, StaticArrays, BenchmarkTools, Compat + +include("../src/linear_eq.jl") + +function randVec(n::Int) + a = randn(n) + A = Interval.(a) + sA = MVector{n}(A) + return A, sA +end + +function randMat(n::Int) + a = randn(n, n) + A = Interval.(a) + sA = MMatrix{n, n}(A) + return A, sA +end + +function benchmark(max=10) + for n in 1:max + A, sA = randMat(n) + b, sb = randVec(n) + println("For n = ", n) + t1 = @btime gauss_seidel_interval($A, $b) + println("Array: ", t1) + t2 = @btime gauss_seidel_interval_static($sA, $sb) + println("MArray: ", t2) + println() + end +end diff --git a/src/benchmark.jl b/src/benchmark.jl deleted file mode 100644 index e78e9071..00000000 --- a/src/benchmark.jl +++ /dev/null @@ -1,17 +0,0 @@ -using IntervalArithmetic, StaticArrays, BenchmarkTools, Compat - -include("linear_eq.jl") - -function randVec(n::Int) - a = randn(n) - A = Interval.(a) - sA = MVector{n}(A) - return A, sA - end - -function randMat(n::Int) - a = randn(n, n) - A = Interval.(a) - sA = MMatrix{n, n}(A) - return A, sA - end