Benchmarks
The performance for some typical operators is summarized below. For fourth-order tensors, both Array
and SArray
use the classical Voigt form to correctly handle symmetries. The benchmakrs show that Tensor
offers performance comparable to SArray
without the hassle of using the Voigt form.
a = rand(Vec{3})
A = rand(SecondOrderTensor{3})
S = rand(SymmetricSecondOrderTensor{3})
AA = rand(FourthOrderTensor{3})
SS = rand(SymmetricFourthOrderTensor{3})
Operation | Tensor | Array | Speedup | SArray | Speedup |
---|---|---|---|---|---|
Single contraction | |||||
a ⊡ a | 3.095 ns | 9.266 ns | ×3.0 | 3.396 ns | ×1.1 |
A ⊡ a | 3.095 ns | 53.918 ns | ×17.0 | 3.406 ns | ×1.1 |
S ⊡ a | 3.406 ns | 53.654 ns | ×16.0 | 3.406 ns | ×1.0 |
Double contraction | |||||
A ⊡₂ A | 3.105 ns | 11.111 ns | ×3.6 | 3.706 ns | ×1.2 |
S ⊡₂ S | 3.396 ns | 10.188 ns | ×3.0 | 3.406 ns | ×1.0 |
AA ⊡₂ A | 7.732 ns | 71.520 ns | ×9.3 | 7.722 ns | ×1.0 |
SS ⊡₂ S | 4.198 ns | 63.680 ns | ×15.0 | 4.157 ns | ×0.99 |
Tensor product | |||||
a ⊗ a | 3.406 ns | 33.295 ns | ×9.8 | 3.406 ns | ×1.0 |
Cross product | |||||
a × a | 3.406 ns | 33.295 ns | ×9.8 | 3.406 ns | ×1.0 |
Determinant | |||||
det(A) | 3.406 ns | 168.049 ns | ×49.0 | 3.406 ns | ×1.0 |
det(S) | 3.095 ns | 162.637 ns | ×53.0 | 3.095 ns | ×1.0 |
Inverse | |||||
inv(A) | 6.192 ns | 477.303 ns | ×77.0 | 7.400 ns | ×1.2 |
inv(S) | 4.929 ns | 455.061 ns | ×92.0 | 7.410 ns | ×1.5 |
inv(AA) | 954.250 ns | 1.513 μs | ×1.6 | 953.136 ns | ×1.0 |
inv(SS) | 363.115 ns | 943.913 ns | ×2.6 | 351.402 ns | ×0.97 |
The benchmarks are generated by runbenchmarks.jl
on the following system:
julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × AMD EPYC 7763 64-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)