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.095 ns | 9.256 ns | ×3.0 | 3.095 ns | ×1.0 |
A ⊡ a | 3.095 ns | 58.268 ns | ×19.0 | 3.095 ns | ×1.0 |
S ⊡ a | 3.406 ns | 59.032 ns | ×17.0 | 3.095 ns | ×0.91 |
Double contraction | |||||
A ⊡₂ A | 3.155 ns | 11.111 ns | ×3.5 | 3.406 ns | ×1.1 |
S ⊡₂ S | 3.406 ns | 10.188 ns | ×3.0 | 3.406 ns | ×1.0 |
AA ⊡₂ A | 7.732 ns | 80.180 ns | ×10.0 | 7.732 ns | ×1.0 |
SS ⊡₂ S | 4.178 ns | 69.361 ns | ×17.0 | 4.368 ns | ×1.0 |
Tensor product | |||||
a ⊗ a | 3.406 ns | 33.537 ns | ×9.8 | 3.406 ns | ×1.0 |
Cross product | |||||
a × a | 3.406 ns | 33.537 ns | ×9.8 | 3.406 ns | ×1.0 |
Determinant | |||||
det(A) | 3.396 ns | 172.760 ns | ×51.0 | 3.406 ns | ×1.0 |
det(S) | 3.095 ns | 173.347 ns | ×56.0 | 3.406 ns | ×1.1 |
Inverse | |||||
inv(A) | 6.181 ns | 532.387 ns | ×86.0 | 7.390 ns | ×1.2 |
inv(S) | 4.869 ns | 488.489 ns | ×100.0 | 7.400 ns | ×1.5 |
inv(AA) | 963.300 ns | 1.597 μs | ×1.7 | 967.647 ns | ×1.0 |
inv(SS) | 360.770 ns | 1.096 μs | ×3.0 | 368.043 ns | ×1.0 |
The benchmarks are generated by runbenchmarks.jl
on the following system:
julia> versioninfo()
Julia Version 1.11.4
Commit 8561cc3d68d (2025-03-10 11:36 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)