Skip to content

Commit f9164ff

Browse files
committed
Add benchmark script
1 parent b225dcd commit f9164ff

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,28 @@
1010
#### Implemented Algorithms:
1111

1212
- Sivan Toledo's recursive left-looking LU algorithm. DOI: [10.1137/S0895479896297744](https://epubs.siam.org/doi/10.1137/S0895479896297744)
13+
14+
#### Performance:
15+
16+
For medium sized mat
17+
```julia
18+
julia> using BenchmarkTools
19+
20+
julia> import LinearAlgebra, RecursiveFactorization
21+
22+
julia> A = rand(40, 40);
23+
24+
julia> @btime RecursiveFactorization.lu($A);
25+
23.762 μs (19 allocations: 26.50 KiB)
26+
27+
julia> @btime LinearAlgebra.lu($A);
28+
63.846 μs (3 allocations: 13.05 KiB)
29+
30+
julia> A = rand(80, 80);
31+
32+
julia> @btime RecursiveFactorization.lu($A);
33+
91.609 μs (42 allocations: 102.95 KiB)
34+
35+
julia> @btime LinearAlgebra.lu($A);
36+
420.470 μs (4 allocations: 50.83 KiB)
37+
```

perf/lu.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using BenchmarkTools
2+
import LinearAlgebra, RecursiveFactorization
3+
4+
BenchmarkTools.DEFAULT_PARAMETERS.seconds = 0.5
5+
6+
luflop(m, n) = n^3÷3 - n÷3 + m*n^2
7+
luflop(n) = luflop(n, n)
8+
9+
bas_mflops = Float64[]
10+
rec_mflops = Float64[]
11+
ns = 50:50:800
12+
for n in ns
13+
A = rand(n, n)
14+
bt = @belapsed LinearAlgebra.lu!($(copy(A)))
15+
rt = @belapsed RecursiveFactorization.lu!($(copy(A)))
16+
push!(bas_mflops, luflop(n)/bt/1e9)
17+
push!(rec_mflops, luflop(n)/rt/1e9)
18+
end
19+
20+
using Plots
21+
plt = plot(ns, bas_mflops, legend=:bottomright, lab="OpenBLAS", title="LU Factorization Benchmark", marker=:auto, dpi=150)
22+
plot!(plt, ns, rec_mflops, lab="RecursiveFactorization", marker=:auto)
23+
xaxis!(plt, "size (N x N)")
24+
yaxis!(plt, "GFLOPS")
25+
savefig("lubench.png")
26+
savefig("lubench.pdf")

0 commit comments

Comments
 (0)