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 | 2.785 ns | 9.256 ns | ×3.3 | 3.095 ns | ×1.1 |
A ⊡ a | 3.396 ns | 53.287 ns | ×16.0 | 3.396 ns | ×1.0 |
S ⊡ a | 3.095 ns | 53.319 ns | ×17.0 | 3.396 ns | ×1.1 |
Double contraction | |||||
A ⊡₂ A | 3.706 ns | 11.111 ns | ×3.0 | 3.406 ns | ×0.92 |
S ⊡₂ S | 3.095 ns | 10.189 ns | ×3.3 | 3.406 ns | ×1.1 |
AA ⊡₂ A | 7.732 ns | 71.817 ns | ×9.3 | 7.742 ns | ×1.0 |
SS ⊡₂ S | 4.278 ns | 63.385 ns | ×15.0 | 4.328 ns | ×1.0 |
Tensor product | |||||
a ⊗ a | 3.707 ns | 33.255 ns | ×9.0 | 3.707 ns | ×1.0 |
Cross product | |||||
a × a | 3.707 ns | 33.255 ns | ×9.0 | 3.707 ns | ×1.0 |
Determinant | |||||
det(A) | 3.095 ns | 171.551 ns | ×55.0 | 3.095 ns | ×1.0 |
det(S) | 3.396 ns | 171.252 ns | ×50.0 | 3.095 ns | ×0.91 |
Inverse | |||||
inv(A) | 6.192 ns | 475.847 ns | ×77.0 | 7.400 ns | ×1.2 |
inv(S) | 4.919 ns | 472.418 ns | ×96.0 | 7.401 ns | ×1.5 |
inv(AA) | 946.364 ns | 1.546 μs | ×1.6 | 961.300 ns | ×1.0 |
inv(SS) | 356.767 ns | 938.944 ns | ×2.6 | 365.850 ns | ×1.0 |
The benchmarks are generated by runbenchmarks.jl
on the following system:
julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 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)