Skip to content

Commit da34ded

Browse files
committed
benchmarks for LU-based matrix functions (det, inv, expm, solve)
1 parent 9bb3ecb commit da34ded

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

perf/bench_matrix_ops.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
Julia Version 0.6.2
2+
Commit d386e40c17* (2017-12-13 18:08 UTC)
3+
Platform Info:
4+
OS: Linux (x86_64-linux-gnu)
5+
CPU: AMD Ryzen 7 1800X Eight-Core Processor
6+
WORD_SIZE: 64
7+
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Barcelona)
8+
LAPACK: libopenblas64_
9+
LIBM: libopenlibm
10+
LLVM: libLLVM-3.9.1 (ORCJIT, generic)
11+
80×6 DataFrames.DataFrame
12+
│ Row │ SIZE │ STAT │ det │ inv │ expm │ \\ │
13+
├─────┼──────┼───────────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
14+
│ 1 │ 1 │ compile time (s) │ 0.0358709 │ 0.00410504 │ 0.029984 │ 0.0932384 │
15+
│ 2 │ │ StaticArrays (μs) │ 0.001813 │ 0.001813 │ 0.0106907 │ 0.004648 │
16+
│ 3 │ │ Base (μs) │ 0.0548293 │ 0.221979 │ 0.77535 │ 0.0877129 │
17+
│ 4 │ │ max error │ 0.0 │ 0.0 │ 0.0 │ 0.0 │
18+
│ 5 │ 2 │ compile time (s) │ 0.00551981 │ 0.00544899 │ 0.0109721 │ 0.109253 │
19+
│ 6 │ │ StaticArrays (μs) │ 0.001813 │ 0.002064 │ 0.0479443 │ 0.0349496 │
20+
│ 7 │ │ Base (μs) │ 0.192087 │ 0.554522 │ 2.60044 │ 1.4488 │
21+
│ 8 │ │ max error │ 2.22045e-16 │ 1.31167e-9 │ 3.17919e-15 │ 2.27485e-13 │
22+
│ 9 │ 3 │ compile time (s) │ 0.0810862 │ 0.0491976 │ 1.11676 │ 0.0138903 │
23+
│ 10 │ │ StaticArrays (μs) │ 0.001853 │ 0.00998799 │ 0.148526 │ 0.0606544 │
24+
│ 11 │ │ Base (μs) │ 0.244762 │ 0.671916 │ 3.19611 │ 1.8104 │
25+
│ 12 │ │ max error │ 2.22045e-16 │ 3.40212e-7 │ 5.55049e-15 │ 8.41688e-11 │
26+
│ 13 │ 4 │ compile time (s) │ 0.0180314 │ 0.846753 │ 1.10441 │ 0.0243759 │
27+
│ 14 │ │ StaticArrays (μs) │ 0.0104805 │ 0.0403582 │ 0.30312 │ 0.113047 │
28+
│ 15 │ │ Base (μs) │ 0.295459 │ 0.92675 │ 5.10971 │ 2.09289 │
29+
│ 16 │ │ max error │ 2.77556e-16 │ 2.62963e-10 │ 1.16735e-14 │ 2.01389e-9 │
30+
│ 17 │ 5 │ compile time (s) │ 2.92353 │ 0.41665 │ 1.58469 │ 0.0376695 │
31+
│ 18 │ │ StaticArrays (μs) │ 0.105874 │ 0.204571 │ 0.519827 │ 0.198071 │
32+
│ 19 │ │ Base (μs) │ 0.373642 │ 1.047 │ 5.89783 │ 2.2522 │
33+
│ 20 │ │ max error │ 1.66533e-16 │ 2.15962e-9 │ 1.84223e-14 │ 5.0253e-10 │
34+
│ 21 │ 6 │ compile time (s) │ 0.594495 │ 0.26922 │ 2.571 │ 0.0567599 │
35+
│ 22 │ │ StaticArrays (μs) │ 0.20246 │ 0.331432 │ 0.83373 │ 0.321775 │
36+
│ 23 │ │ Base (μs) │ 0.442449 │ 1.2143 │ 6.5424 │ 2.3995 │
37+
│ 24 │ │ max error │ 1.66533e-16 │ 1.53235e-8 │ 4.67587e-14 │ 6.4429e-9 │
38+
│ 25 │ 7 │ compile time (s) │ 0.679751 │ 0.367467 │ 4.41147 │ 0.0837663 │
39+
│ 26 │ │ StaticArrays (μs) │ 0.285484 │ 0.479979 │ 1.3115 │ 0.481318 │
40+
│ 27 │ │ Base (μs) │ 0.533771 │ 1.4007 │ 7.57425 │ 2.65178 │
41+
│ 28 │ │ max error │ 1.66533e-16 │ 1.54685e-7 │ 1.13318e-13 │ 3.0299e-9 │
42+
│ 29 │ 8 │ compile time (s) │ 0.798822 │ 0.501215 │ 7.42485 │ 0.125385 │
43+
│ 30 │ │ StaticArrays (μs) │ 0.400655 │ 0.672679 │ 1.7624 │ 0.678955 │
44+
│ 31 │ │ Base (μs) │ 0.613287 │ 1.603 │ 8.035 │ 2.94444 │
45+
│ 32 │ │ max error │ 2.77556e-16 │ 4.73129e-9 │ 1.46772e-13 │ 2.61726e-9 │
46+
│ 33 │ 9 │ compile time (s) │ 0.91446 │ 0.677859 │ 3.29461 │ 0.188982 │
47+
│ 34 │ │ StaticArrays (μs) │ 0.574361 │ 0.9838 │ 2.81078 │ 0.965474 │
48+
│ 35 │ │ Base (μs) │ 0.7649 │ 1.8765 │ 9.128 │ 3.17475 │
49+
│ 36 │ │ max error │ 3.46945e-16 │ 6.68251e-9 │ 3.30702e-13 │ 2.04139e-9 │
50+
│ 37 │ 10 │ compile time (s) │ 1.09413 │ 0.923797 │ 4.16234 │ 0.258198 │
51+
│ 38 │ │ StaticArrays (μs) │ 0.770716 │ 1.3145 │ 4.16643 │ 1.3064 │
52+
│ 39 │ │ Base (μs) │ 2.82311 │ 4.12057 │ 12.835 │ 5.3835 │
53+
│ 40 │ │ max error │ 1.94289e-16 │ 1.7691e-9 │ 2.42841e-13 │ 1.97784e-9 │
54+
│ 41 │ 11 │ compile time (s) │ 1.30448 │ 1.21905 │ 5.35341 │ 0.396076 │
55+
│ 42 │ │ StaticArrays (μs) │ 1.037 │ 1.7583 │ 5.43033 │ 1.7323 │
56+
│ 43 │ │ Base (μs) │ 3.24737 │ 4.82417 │ 16.481 │ 6.83967 │
57+
│ 44 │ │ max error │ 2.42861e-16 │ 1.91576e-9 │ 5.14422e-13 │ 3.63391e-9 │
58+
│ 45 │ 12 │ compile time (s) │ 1.55567 │ 1.66793 │ 6.75529 │ 0.601386 │
59+
│ 46 │ │ StaticArrays (μs) │ 1.3044 │ 2.203 │ 6.8148 │ 2.18522 │
60+
│ 47 │ │ Base (μs) │ 3.3915 │ 5.04783 │ 15.549 │ 6.2778 │
61+
│ 48 │ │ max error │ 2.77556e-16 │ 6.40505e-10 │ 7.41502e-13 │ 9.72575e-10 │
62+
│ 49 │ 13 │ compile time (s) │ 1.93222 │ 2.21769 │ 8.61503 │ 0.847173 │
63+
│ 50 │ │ StaticArrays (μs) │ 1.6922 │ 2.83978 │ 8.623 │ 2.812 │
64+
│ 51 │ │ Base (μs) │ 3.841 │ 5.813 │ 25.147 │ 6.2298 │
65+
│ 52 │ │ max error │ 2.22045e-16 │ 3.45741e-8 │ 1.43535e-12 │ 3.7065e-10 │
66+
│ 53 │ 14 │ compile time (s) │ 2.26075 │ 2.94048 │ 10.9119 │ 1.22455 │
67+
│ 54 │ │ StaticArrays (μs) │ 2.11289 │ 3.49162 │ 10.63 │ 3.43775 │
68+
│ 55 │ │ Base (μs) │ 6.0394 │ 8.1555 │ 29.706 │ 8.3256 │
69+
│ 56 │ │ max error │ 5.55112e-16 │ 2.75214e-8 │ 2.81287e-12 │ 1.23022e-8 │
70+
│ 57 │ 15 │ compile time (s) │ 0.0109467 │ 0.0650982 │ 16.0084 │ 0.059017 │
71+
│ 58 │ │ StaticArrays (μs) │ 6.788 │ 8.787 │ 37.942 │ 11.321 │
72+
│ 59 │ │ Base (μs) │ 6.6 │ 8.43933 │ 24.837 │ 9.819 │
73+
│ 60 │ │ max error │ 0.0 │ 0.0 │ 6.88512e-12 │ 0.0 │
74+
│ 61 │ 16 │ compile time (s) │ 0.0108788 │ 0.0883042 │ 18.8852 │ 0.0656792 │
75+
│ 62 │ │ StaticArrays (μs) │ 7.4815 │ 10.4963 │ 44.585 │ 11.091 │
76+
│ 63 │ │ Base (μs) │ 7.116 │ 9.638 │ 36.8 │ 12.223 │
77+
│ 64 │ │ max error │ 0.0 │ 0.0 │ 8.35981e-12 │ 0.0 │
78+
│ 65 │ 17 │ compile time (s) │ 0.0110253 │ 0.103676 │ 23.3029 │ 0.0761904 │
79+
│ 66 │ │ StaticArrays (μs) │ 8.656 │ 11.402 │ 53.001 │ 10.37 │
80+
│ 67 │ │ Base (μs) │ 8.386 │ 11.592 │ 47.86 │ 12.814 │
81+
│ 68 │ │ max error │ 0.0 │ 0.0 │ 2.26813e-11 │ 0.0 │
82+
│ 69 │ 18 │ compile time (s) │ 0.0128607 │ 0.0897007 │ 27.215 │ 0.0820536 │
83+
│ 70 │ │ StaticArrays (μs) │ 11.061 │ 13.706 │ 62.048 │ 17.152 │
84+
│ 71 │ │ Base (μs) │ 12.584 │ 14.096 │ 55.174 │ 14.878 │
85+
│ 72 │ │ max error │ 0.0 │ 0.0 │ 1.89276e-11 │ 0.0 │
86+
│ 73 │ 19 │ compile time (s) │ 0.0110386 │ 0.113333 │ 32.6636 │ 0.090609 │
87+
│ 74 │ │ StaticArrays (μs) │ 10.48 │ 14.387 │ 71.615 │ 17.143 │
88+
│ 75 │ │ Base (μs) │ 13.325 │ 13.636 │ 60.074 │ 12.513 │
89+
│ 76 │ │ max error │ 0.0 │ 0.0 │ 2.97618e-11 │ 0.0 │
90+
│ 77 │ 20 │ compile time (s) │ 0.0111067 │ 0.110741 │ 39.7384 │ 0.0973694 │
91+
│ 78 │ │ StaticArrays (μs) │ 11.2547 │ 14.768 │ 69.351 │ 13.365 │
92+
│ 79 │ │ Base (μs) │ 10.59 │ 13.887 │ 62.789 │ 17.813 │
93+
│ 80 │ │ max error │ 0.0 │ 0.0 │ 1.64377e-11 │ 0.0 │

perf/benchmark_matrix_ops.jl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using StaticArrays, BenchmarkTools, DataFrames, DataStructures
2+
3+
Nmax = 20
4+
unary = (det, inv, expm)
5+
binary = (\,)
6+
7+
data = OrderedDict{Symbol,Any}()
8+
data[:SIZE] = vcat(([i, "", "", ""] for i in 1:Nmax)...)
9+
data[:STAT] = [stat for sz in 1:Nmax for stat in ("compile time (s)", "StaticArrays (μs)", "Base (μs)", "max error")]
10+
11+
for f in unary
12+
f_data = Float64[]
13+
for N in 1:Nmax
14+
print("\r$((f,N))")
15+
SA = @SMatrix rand(N,N)
16+
A = Array(SA)
17+
push!(f_data, @elapsed f(SA))
18+
push!(f_data, 1e6*@belapsed $f($SA))
19+
push!(f_data, 1e6*@belapsed $f($A))
20+
push!(f_data, maximum([begin
21+
SA = @SMatrix rand(N,N)
22+
A = Array(SA)
23+
norm(f(A) - f(SA))
24+
end for i in 1:1000]))
25+
end
26+
data[Symbol(f)] = f_data
27+
end
28+
29+
for f in binary
30+
f_data = Float64[]
31+
for N in 1:Nmax
32+
print("\r$((f,N))")
33+
SA = @SMatrix rand(N,N)
34+
A = Array(SA)
35+
SB = @SMatrix rand(N,N)
36+
B = Array(SB)
37+
push!(f_data, @elapsed f(SA,SB))
38+
push!(f_data, 1e6*@belapsed $f($SA,$SB))
39+
push!(f_data, 1e6*@belapsed $f($A,$B))
40+
push!(f_data, maximum([begin
41+
SA = @SMatrix rand(N,N)
42+
A = Array(SA)
43+
SB = @SMatrix rand(N,N)
44+
B = Array(SB)
45+
norm(f(A,B) - f(SA,SB))
46+
end for i in 1:1000]))
47+
end
48+
data[Symbol(f)] = f_data
49+
end
50+
51+
df = DataFrame(data...)
52+
53+
open("bench_matrix_ops.txt", "w") do f
54+
versioninfo(f)
55+
showall(f, df)
56+
end

0 commit comments

Comments
 (0)