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})
OperationTensorArraySpeedupSArraySpeedup
Single contraction
a ⊡ a3.095 ns9.266 ns×3.03.396 ns×1.1
A ⊡ a3.095 ns53.918 ns×17.03.406 ns×1.1
S ⊡ a3.406 ns53.654 ns×16.03.406 ns×1.0
Double contraction
A ⊡₂ A3.105 ns11.111 ns×3.63.706 ns×1.2
S ⊡₂ S3.396 ns10.188 ns×3.03.406 ns×1.0
AA ⊡₂ A7.732 ns71.520 ns×9.37.722 ns×1.0
SS ⊡₂ S4.198 ns63.680 ns×15.04.157 ns×0.99
Tensor product
a ⊗ a3.406 ns33.295 ns×9.83.406 ns×1.0
Cross product
a × a3.406 ns33.295 ns×9.83.406 ns×1.0
Determinant
det(A)3.406 ns168.049 ns×49.03.406 ns×1.0
det(S)3.095 ns162.637 ns×53.03.095 ns×1.0
Inverse
inv(A)6.192 ns477.303 ns×77.07.400 ns×1.2
inv(S)4.929 ns455.061 ns×92.07.410 ns×1.5
inv(AA)954.250 ns1.513 μs×1.6953.136 ns×1.0
inv(SS)363.115 ns943.913 ns×2.6351.402 ns×0.97

The benchmarks are generated by runbenchmarks.jl on the following system:

julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10: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)