How can it be:
Matrix inv(A) where A 150x150 matrix twice slower (2.643 ms) than in R (1.049 ms). But invercing by blocks in R ( 3.275 ms) slower than in Julia (58.917 μs) many times. Second not surprising, but first… How peroformance like in R can be achived?
using RCall
using BlockDiagonals
using LinearAlgebra
using BenchmarkTools
blocks = [rand(3,3) for i in 1:50]
BDm = BlockDiagonal(blocks)
V = Matrix(BDm)
sBDm = BlockDiagonal(sblocks)
@rput V
@rput blocks
b1 = @benchmark inv(V)
b2 = @benchmark inv.(blocks)
b3 = @benchmark inv(BDm)
b4 = @benchmark R"solve(V)"
b5 = @benchmark R"for (i in 1:50) {solve(blocks[[i]])}"
#=
julia> b1
BenchmarkTools.Trial:
memory estimate: 252.41 KiB
allocs estimate: 6
--------------
minimum time: 1.297 ms (0.00% GC)
median time: 1.610 ms (0.00% GC)
mean time: 2.643 ms (0.29% GC)
maximum time: 305.198 ms (0.00% GC)
--------------
samples: 1888
evals/sample: 1
julia> b2
BenchmarkTools.Trial:
memory estimate: 99.73 KiB
allocs estimate: 253
--------------
minimum time: 32.200 μs (0.00% GC)
median time: 39.999 μs (0.00% GC)
mean time: 58.917 μs (9.61% GC)
maximum time: 4.830 ms (98.32% GC)
--------------
samples: 10000
evals/sample: 1
julia> b3
BenchmarkTools.Trial:
memory estimate: 99.73 KiB
allocs estimate: 253
--------------
minimum time: 31.900 μs (0.00% GC)
median time: 39.299 μs (0.00% GC)
mean time: 56.484 μs (9.13% GC)
maximum time: 4.496 ms (0.00% GC)
--------------
samples: 10000
evals/sample: 1
julia> b4
BenchmarkTools.Trial:
memory estimate: 1.06 KiB
allocs estimate: 30
--------------
minimum time: 637.901 μs (0.00% GC)
median time: 783.800 μs (0.00% GC)
mean time: 1.049 ms (0.00% GC)
maximum time: 32.893 ms (0.00% GC)
--------------
samples: 4713
evals/sample: 1
julia> b5
BenchmarkTools.Trial:
memory estimate: 1.06 KiB
allocs estimate: 30
--------------
minimum time: 1.916 ms (0.00% GC)
median time: 2.508 ms (0.00% GC)
mean time: 3.275 ms (0.00% GC)
maximum time: 26.751 ms (0.00% GC)
--------------
samples: 1520
evals/sample: 1
julia>
=#