From 5ead6c8693104daeccbed91dcc26dc4eb679d750 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 19 Feb 2020 18:22:51 -0800 Subject: [PATCH 1/5] [ci skip] Port perf/benchmark_matrix_ops.jl to benchmark/*.jl --- benchmark/bench_matrix_ops.jl | 41 +++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 benchmark/bench_matrix_ops.jl diff --git a/benchmark/bench_matrix_ops.jl b/benchmark/bench_matrix_ops.jl new file mode 100644 index 00000000..2de39ce5 --- /dev/null +++ b/benchmark/bench_matrix_ops.jl @@ -0,0 +1,41 @@ +module BenchMatrixOps + +using BenchmarkTools +using LinearAlgebra +using Random +using StaticArrays + +const suite = BenchmarkGroup() +const Nmax = 20 + +# Use same arrays across processes (at least with the same Julia version): +const RNG = MersenneTwister(1234) + +# Unary operators +for f in [det, inv, exp] + s1 = suite["$f"] = BenchmarkGroup() + for N in 1:Nmax + SA = @SMatrix rand(RNG, N, N) + A = Array(SA) + s2 = s1["$N"] = BenchmarkGroup() + s2["SMatrix"] = @benchmarkable $f($SA) + s2["Matrix"] = @benchmarkable $f($A) + end +end + +# Binary operators +for f in [*, \] + s1 = suite["$f"] = BenchmarkGroup() + for N in 1:Nmax + SA = @SMatrix rand(RNG, N, N) + SB = @SMatrix rand(RNG, N, N) + A = Array(SA) + B = Array(SB) + s2 = s1["$N"] = BenchmarkGroup() + s2["SMatrix"] = @benchmarkable $f($SA, $SB) + s2["Matrix"] = @benchmarkable $f($A, $B) + end +end + +end # module +BenchMatrixOps.suite From d9ca659fd104f6b5f09030d11cd48db515e50546 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 19 Feb 2020 18:40:21 -0800 Subject: [PATCH 2/5] [ci skip] Add Random to benchmark/Project.toml --- benchmark/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/benchmark/Project.toml b/benchmark/Project.toml index 3cbe72fa..5a82d61b 100644 --- a/benchmark/Project.toml +++ b/benchmark/Project.toml @@ -2,3 +2,4 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" PkgBenchmark = "32113eaa-f34f-5b0d-bd6c-c81e245fc73d" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" From 2f6923567cb96d3f308f4775d631c8a40b1a76c4 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 19 Feb 2020 18:36:18 -0800 Subject: [PATCH 3/5] [ci skip] Fix `rand` usage --- benchmark/bench_matrix_ops.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmark/bench_matrix_ops.jl b/benchmark/bench_matrix_ops.jl index 2de39ce5..79e3b5dd 100644 --- a/benchmark/bench_matrix_ops.jl +++ b/benchmark/bench_matrix_ops.jl @@ -1,21 +1,21 @@ module BenchMatrixOps +import Random using BenchmarkTools using LinearAlgebra -using Random using StaticArrays const suite = BenchmarkGroup() const Nmax = 20 # Use same arrays across processes (at least with the same Julia version): -const RNG = MersenneTwister(1234) +Random.seed!(1234) # Unary operators for f in [det, inv, exp] s1 = suite["$f"] = BenchmarkGroup() for N in 1:Nmax - SA = @SMatrix rand(RNG, N, N) + SA = @SMatrix rand(N, N) A = Array(SA) s2 = s1["$N"] = BenchmarkGroup() s2["SMatrix"] = @benchmarkable $f($SA) @@ -27,8 +27,8 @@ end for f in [*, \] s1 = suite["$f"] = BenchmarkGroup() for N in 1:Nmax - SA = @SMatrix rand(RNG, N, N) - SB = @SMatrix rand(RNG, N, N) + SA = @SMatrix rand(N, N) + SB = @SMatrix rand(N, N) A = Array(SA) B = Array(SB) s2 = s1["$N"] = BenchmarkGroup() From 298f375dd09970e197bda26840a4f18535b04be9 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Wed, 19 Feb 2020 18:50:04 -0800 Subject: [PATCH 4/5] [ci skip] Reduce number of benchmarks to run in CI --- benchmark/bench_matrix_ops.jl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/benchmark/bench_matrix_ops.jl b/benchmark/bench_matrix_ops.jl index 79e3b5dd..1568f5cd 100644 --- a/benchmark/bench_matrix_ops.jl +++ b/benchmark/bench_matrix_ops.jl @@ -6,7 +6,11 @@ using LinearAlgebra using StaticArrays const suite = BenchmarkGroup() -const Nmax = 20 +const matrix_sizes = if haskey(ENV, "GITHUB_EVENT_PATH") + (1, 2, 3, 4, 10, 20) +else + 1:20 +end # Use same arrays across processes (at least with the same Julia version): Random.seed!(1234) @@ -14,7 +18,7 @@ Random.seed!(1234) # Unary operators for f in [det, inv, exp] s1 = suite["$f"] = BenchmarkGroup() - for N in 1:Nmax + for N in matrix_sizes SA = @SMatrix rand(N, N) A = Array(SA) s2 = s1["$N"] = BenchmarkGroup() @@ -26,7 +30,7 @@ end # Binary operators for f in [*, \] s1 = suite["$f"] = BenchmarkGroup() - for N in 1:Nmax + for N in matrix_sizes SA = @SMatrix rand(N, N) SB = @SMatrix rand(N, N) A = Array(SA) From 479b0ca86a01e012420b24b5933d0668a9974d3c Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Thu, 20 Feb 2020 19:17:28 -0800 Subject: [PATCH 5/5] Pad benchmark names Co-Authored-By: Chris Foster --- benchmark/bench_matrix_ops.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/bench_matrix_ops.jl b/benchmark/bench_matrix_ops.jl index 1568f5cd..2795c1e2 100644 --- a/benchmark/bench_matrix_ops.jl +++ b/benchmark/bench_matrix_ops.jl @@ -21,7 +21,7 @@ for f in [det, inv, exp] for N in matrix_sizes SA = @SMatrix rand(N, N) A = Array(SA) - s2 = s1["$N"] = BenchmarkGroup() + s2 = s1[string(N, pad=2)] = BenchmarkGroup() s2["SMatrix"] = @benchmarkable $f($SA) s2["Matrix"] = @benchmarkable $f($A) end @@ -35,7 +35,7 @@ for f in [*, \] SB = @SMatrix rand(N, N) A = Array(SA) B = Array(SB) - s2 = s1["$N"] = BenchmarkGroup() + s2 = s1[string(N, pad=2)] = BenchmarkGroup() s2["SMatrix"] = @benchmarkable $f($SA, $SB) s2["Matrix"] = @benchmarkable $f($A, $B) end