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 | 8.955 ns | ×3.2 | 3.095 ns | ×1.1 |
A ⊡ a | 3.396 ns | 49.343 ns | ×15.0 | 3.095 ns | ×0.91 |
S ⊡ a | 3.396 ns | 49.232 ns | ×14.0 | 3.095 ns | ×0.91 |
| Double contraction | |||||
A ⊡₂ A | 3.396 ns | 10.801 ns | ×3.2 | 3.406 ns | ×1.0 |
S ⊡₂ S | 3.095 ns | 9.878 ns | ×3.2 | 3.406 ns | ×1.1 |
AA ⊡₂ A | 7.722 ns | 67.834 ns | ×8.8 | 7.722 ns | ×1.0 |
SS ⊡₂ S | 4.087 ns | 61.141 ns | ×15.0 | 4.028 ns | ×0.99 |
| Tensor product | |||||
a ⊗ a | 3.105 ns | 28.626 ns | ×9.2 | 3.406 ns | ×1.1 |
| Cross product | |||||
a × a | 3.105 ns | 28.626 ns | ×9.2 | 3.406 ns | ×1.1 |
| Determinant | |||||
det(A) | 3.095 ns | 167.872 ns | ×54.0 | 3.397 ns | ×1.1 |
det(S) | 3.095 ns | 169.235 ns | ×55.0 | 3.406 ns | ×1.1 |
| Inverse | |||||
inv(A) | 6.221 ns | 467.250 ns | ×75.0 | 7.410 ns | ×1.2 |
inv(S) | 4.889 ns | 473.026 ns | ×97.0 | 7.391 ns | ×1.5 |
inv(AA) | 974.312 ns | 1.566 μs | ×1.6 | 973.625 ns | ×1.0 |
inv(SS) | 383.733 ns | 986.000 ns | ×2.6 | 373.784 ns | ×0.97 |
The benchmarks are generated by runbenchmarks.jl on the following system:
julia> versioninfo()
Julia Version 1.12.5
Commit 5fe89b8ddc1 (2026-02-09 16:05 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-18.1.7 (ORCJIT, znver3)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)