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.396 ns | 9.266 ns | ×2.7 | 3.095 ns | ×0.91 |
A ⊡ a | 3.406 ns | 54.434 ns | ×16.0 | 3.406 ns | ×1.0 |
S ⊡ a | 3.706 ns | 54.385 ns | ×15.0 | 3.406 ns | ×0.92 |
Double contraction | |||||
A ⊡₂ A | 3.406 ns | 11.121 ns | ×3.3 | 3.406 ns | ×1.0 |
S ⊡₂ S | 3.406 ns | 10.189 ns | ×3.0 | 3.406 ns | ×1.0 |
AA ⊡₂ A | 7.742 ns | 74.949 ns | ×9.7 | 7.732 ns | ×1.0 |
SS ⊡₂ S | 4.198 ns | 68.230 ns | ×16.0 | 4.138 ns | ×0.99 |
Tensor product | |||||
a ⊗ a | 3.406 ns | 32.959 ns | ×9.7 | 3.716 ns | ×1.1 |
Cross product | |||||
a × a | 3.406 ns | 32.959 ns | ×9.7 | 3.716 ns | ×1.1 |
Determinant | |||||
det(A) | 3.095 ns | 172.657 ns | ×56.0 | 3.095 ns | ×1.0 |
det(S) | 3.095 ns | 172.167 ns | ×56.0 | 3.095 ns | ×1.0 |
Inverse | |||||
inv(A) | 6.241 ns | 473.230 ns | ×76.0 | 7.420 ns | ×1.2 |
inv(S) | 4.929 ns | 473.689 ns | ×96.0 | 7.411 ns | ×1.5 |
inv(AA) | 946.471 ns | 1.512 μs | ×1.6 | 950.810 ns | ×1.0 |
inv(SS) | 364.284 ns | 943.529 ns | ×2.6 | 369.786 ns | ×1.0 |
The benchmarks are generated by runbenchmarks.jl
on the following system:
julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06: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)