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 | 8.955 ns | ×2.6 | 3.095 ns | ×0.91 |
A ⊡ a | 3.095 ns | 49.443 ns | ×16.0 | 3.406 ns | ×1.1 |
S ⊡ a | 3.406 ns | 49.130 ns | ×14.0 | 3.406 ns | ×1.0 |
| Double contraction | |||||
A ⊡₂ A | 3.406 ns | 10.810 ns | ×3.2 | 3.105 ns | ×0.91 |
S ⊡₂ S | 3.095 ns | 9.878 ns | ×3.2 | 3.116 ns | ×1.0 |
AA ⊡₂ A | 7.722 ns | 67.731 ns | ×8.8 | 7.722 ns | ×1.0 |
SS ⊡₂ S | 4.068 ns | 59.154 ns | ×15.0 | 4.037 ns | ×0.99 |
| Tensor product | |||||
a ⊗ a | 3.105 ns | 28.958 ns | ×9.3 | 3.406 ns | ×1.1 |
| Cross product | |||||
a × a | 3.105 ns | 28.958 ns | ×9.3 | 3.406 ns | ×1.1 |
| Determinant | |||||
det(A) | 3.406 ns | 166.262 ns | ×49.0 | 3.095 ns | ×0.91 |
det(S) | 3.095 ns | 166.632 ns | ×54.0 | 3.095 ns | ×1.0 |
| Inverse | |||||
inv(A) | 6.201 ns | 464.286 ns | ×75.0 | 7.420 ns | ×1.2 |
inv(S) | 4.889 ns | 465.636 ns | ×95.0 | 7.411 ns | ×1.5 |
inv(AA) | 971.071 ns | 1.554 μs | ×1.6 | 980.059 ns | ×1.0 |
inv(SS) | 383.315 ns | 911.238 ns | ×2.4 | 371.951 ns | ×0.97 |
The benchmarks are generated by runbenchmarks.jl on the following system:
julia> versioninfo()
Julia Version 1.12.4
Commit 01a2eadb047 (2026-01-06 16:56 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)