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.396 ns9.266 ns×2.73.095 ns×0.91
A ⊡ a3.406 ns54.434 ns×16.03.406 ns×1.0
S ⊡ a3.706 ns54.385 ns×15.03.406 ns×0.92
Double contraction
A ⊡₂ A3.406 ns11.121 ns×3.33.406 ns×1.0
S ⊡₂ S3.406 ns10.189 ns×3.03.406 ns×1.0
AA ⊡₂ A7.742 ns74.949 ns×9.77.732 ns×1.0
SS ⊡₂ S4.198 ns68.230 ns×16.04.138 ns×0.99
Tensor product
a ⊗ a3.406 ns32.959 ns×9.73.716 ns×1.1
Cross product
a × a3.406 ns32.959 ns×9.73.716 ns×1.1
Determinant
det(A)3.095 ns172.657 ns×56.03.095 ns×1.0
det(S)3.095 ns172.167 ns×56.03.095 ns×1.0
Inverse
inv(A)6.241 ns473.230 ns×76.07.420 ns×1.2
inv(S)4.929 ns473.689 ns×96.07.411 ns×1.5
inv(AA)946.471 ns1.512 μs×1.6950.810 ns×1.0
inv(SS)364.284 ns943.529 ns×2.6369.786 ns×1.0

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)