File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 22BenchmarkTools = " 6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
33LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
44PkgBenchmark = " 32113eaa-f34f-5b0d-bd6c-c81e245fc73d"
5+ Random = " 9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Original file line number Diff line number Diff line change 1+ module BenchMatrixOps
2+
3+ import Random
4+ using BenchmarkTools
5+ using LinearAlgebra
6+ using StaticArrays
7+
8+ const suite = BenchmarkGroup ()
9+ const matrix_sizes = if haskey (ENV , " GITHUB_EVENT_PATH" )
10+ (1 , 2 , 3 , 4 , 10 , 20 )
11+ else
12+ 1 : 20
13+ end
14+
15+ # Use same arrays across processes (at least with the same Julia version):
16+ Random. seed! (1234 )
17+
18+ # Unary operators
19+ for f in [det, inv, exp]
20+ s1 = suite[" $f " ] = BenchmarkGroup ()
21+ for N in matrix_sizes
22+ SA = @SMatrix rand (N, N)
23+ A = Array (SA)
24+ s2 = s1[string (N, pad= 2 )] = BenchmarkGroup ()
25+ s2[" SMatrix" ] = @benchmarkable $ f ($ SA)
26+ s2[" Matrix" ] = @benchmarkable $ f ($ A)
27+ end
28+ end
29+
30+ # Binary operators
31+ for f in [* , \ ]
32+ s1 = suite[" $f " ] = BenchmarkGroup ()
33+ for N in matrix_sizes
34+ SA = @SMatrix rand (N, N)
35+ SB = @SMatrix rand (N, N)
36+ A = Array (SA)
37+ B = Array (SB)
38+ s2 = s1[string (N, pad= 2 )] = BenchmarkGroup ()
39+ s2[" SMatrix" ] = @benchmarkable $ f ($ SA, $ SB)
40+ s2[" Matrix" ] = @benchmarkable $ f ($ A, $ B)
41+ end
42+ end
43+
44+ end # module
45+ BenchMatrixOps. suite
You can’t perform that action at this time.
0 commit comments