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.085 ns | ×1.1 |
A ⊡ a | 3.095 ns | 49.313 ns | ×16.0 | 3.396 ns | ×1.1 |
S ⊡ a | 3.095 ns | 49.403 ns | ×16.0 | 3.396 ns | ×1.1 |
| Double contraction | |||||
A ⊡₂ A | 3.396 ns | 10.801 ns | ×3.2 | 3.396 ns | ×1.0 |
S ⊡₂ S | 3.095 ns | 9.878 ns | ×3.2 | 3.396 ns | ×1.1 |
AA ⊡₂ A | 7.722 ns | 67.691 ns | ×8.8 | 7.722 ns | ×1.0 |
SS ⊡₂ S | 4.277 ns | 59.134 ns | ×14.0 | 4.308 ns | ×1.0 |
| Tensor product | |||||
a ⊗ a | 3.406 ns | 28.536 ns | ×8.4 | 3.396 ns | ×1.0 |
| Cross product | |||||
a × a | 3.406 ns | 28.536 ns | ×8.4 | 3.396 ns | ×1.0 |
| Determinant | |||||
det(A) | 3.095 ns | 162.834 ns | ×53.0 | 3.095 ns | ×1.0 |
det(S) | 3.095 ns | 168.708 ns | ×55.0 | 3.095 ns | ×1.0 |
| Inverse | |||||
inv(A) | 6.241 ns | 431.616 ns | ×69.0 | 7.410 ns | ×1.2 |
inv(S) | 4.939 ns | 459.949 ns | ×93.0 | 7.410 ns | ×1.5 |
inv(AA) | 979.611 ns | 1.521 μs | ×1.6 | 972.842 ns | ×0.99 |
inv(SS) | 397.591 ns | 969.091 ns | ×2.4 | 367.551 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 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)