Skip to content

Commit

Permalink
Port perf/benchmark_matrix_ops.jl to benchmark/*.jl (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored Feb 26, 2020
1 parent c3686c4 commit f330604
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions benchmark/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
45 changes: 45 additions & 0 deletions benchmark/bench_matrix_ops.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module BenchMatrixOps

import Random
using BenchmarkTools
using LinearAlgebra
using StaticArrays

const suite = BenchmarkGroup()
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)

# Unary operators
for f in [det, inv, exp]
s1 = suite["$f"] = BenchmarkGroup()
for N in matrix_sizes
SA = @SMatrix rand(N, N)
A = Array(SA)
s2 = s1[string(N, pad=2)] = 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 matrix_sizes
SA = @SMatrix rand(N, N)
SB = @SMatrix rand(N, N)
A = Array(SA)
B = Array(SB)
s2 = s1[string(N, pad=2)] = BenchmarkGroup()
s2["SMatrix"] = @benchmarkable $f($SA, $SB)
s2["Matrix"] = @benchmarkable $f($A, $B)
end
end

end # module
BenchMatrixOps.suite

0 comments on commit f330604

Please sign in to comment.