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 | 9.266 ns | ×3.3 | 2.785 ns | ×1.0 |
A ⊡ a | 3.095 ns | 55.766 ns | ×18.0 | 3.095 ns | ×1.0 |
S ⊡ a | 3.406 ns | 55.806 ns | ×16.0 | 3.095 ns | ×0.91 |
Double contraction | |||||
A ⊡₂ A | 3.406 ns | 11.121 ns | ×3.3 | 3.707 ns | ×1.1 |
S ⊡₂ S | 3.095 ns | 10.189 ns | ×3.3 | 3.706 ns | ×1.2 |
AA ⊡₂ A | 7.732 ns | 77.452 ns | ×10.0 | 7.732 ns | ×1.0 |
SS ⊡₂ S | 4.067 ns | 70.933 ns | ×17.0 | 4.258 ns | ×1.0 |
Tensor product | |||||
a ⊗ a | 3.406 ns | 32.841 ns | ×9.6 | 3.416 ns | ×1.0 |
Cross product | |||||
a × a | 3.406 ns | 32.841 ns | ×9.6 | 3.416 ns | ×1.0 |
Determinant | |||||
det(A) | 3.396 ns | 173.918 ns | ×51.0 | 3.095 ns | ×0.91 |
det(S) | 3.095 ns | 174.391 ns | ×56.0 | 3.095 ns | ×1.0 |
Inverse | |||||
inv(A) | 6.582 ns | 496.368 ns | ×75.0 | 7.410 ns | ×1.1 |
inv(S) | 4.929 ns | 496.731 ns | ×100.0 | 7.411 ns | ×1.5 |
inv(AA) | 944.333 ns | 1.514 μs | ×1.6 | 946.960 ns | ×1.0 |
inv(SS) | 358.014 ns | 990.900 ns | ×2.8 | 356.048 ns | ×0.99 |
The benchmarks are generated by runbenchmarks.jl
on the following system:
julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b739 (2025-04-14 06:53 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)