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.475 ns | 8.030 ns | ×2.3 | 3.475 ns | ×1.0 |
A ⊡ a | 3.485 ns | 47.916 ns | ×14.0 | 3.485 ns | ×1.0 |
S ⊡ a | 3.835 ns | 48.108 ns | ×13.0 | 3.485 ns | ×0.91 |
| Double contraction | |||||
A ⊡₂ A | 3.835 ns | 10.195 ns | ×2.7 | 3.825 ns | ×1.0 |
S ⊡₂ S | 3.825 ns | 9.102 ns | ×2.4 | 3.825 ns | ×1.0 |
AA ⊡₂ A | 8.552 ns | 68.207 ns | ×8.0 | 8.552 ns | ×1.0 |
SS ⊡₂ S | 4.386 ns | 60.784 ns | ×14.0 | 4.416 ns | ×1.0 |
| Tensor product | |||||
a ⊗ a | 3.485 ns | 29.883 ns | ×8.6 | 3.825 ns | ×1.1 |
| Cross product | |||||
a × a | 3.485 ns | 29.883 ns | ×8.6 | 3.825 ns | ×1.1 |
| Determinant | |||||
det(A) | 3.825 ns | 179.296 ns | ×47.0 | 3.476 ns | ×0.91 |
det(S) | 3.475 ns | 175.237 ns | ×50.0 | 3.485 ns | ×1.0 |
| Inverse | |||||
inv(A) | 6.480 ns | 421.638 ns | ×65.0 | 8.622 ns | ×1.3 |
inv(S) | 4.546 ns | 408.452 ns | ×90.0 | 8.621 ns | ×1.9 |
inv(AA) | 1.054 μs | 1.513 μs | ×1.4 | 1.054 μs | ×1.0 |
inv(SS) | 434.874 ns | 914.160 ns | ×2.1 | 398.557 ns | ×0.92 |
The benchmarks are generated by runbenchmarks.jl on the following system:
julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × AMD EPYC 9V74 80-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, znver4)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)