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 ⊡ a2.785 ns9.256 ns×3.32.785 ns×1.0
A ⊡ a3.095 ns53.888 ns×17.03.095 ns×1.0
S ⊡ a3.095 ns53.806 ns×17.03.095 ns×1.0
Double contraction
A ⊡₂ A3.406 ns11.111 ns×3.33.706 ns×1.1
S ⊡₂ S3.095 ns10.188 ns×3.33.706 ns×1.2
AA ⊡₂ A7.723 ns72.107 ns×9.37.722 ns×1.0
SS ⊡₂ S4.037 ns67.150 ns×17.04.117 ns×1.0
Tensor product
a ⊗ a3.706 ns33.668 ns×9.13.406 ns×0.92
Cross product
a × a3.706 ns33.668 ns×9.13.406 ns×0.92
Determinant
det(A)3.095 ns168.433 ns×54.03.095 ns×1.0
det(S)3.095 ns169.929 ns×55.03.095 ns×1.0
Inverse
inv(A)6.261 ns471.949 ns×75.07.400 ns×1.2
inv(S)4.929 ns492.528 ns×100.07.400 ns×1.5
inv(AA)950.478 ns1.503 μs×1.6961.818 ns×1.0
inv(SS)365.609 ns958.929 ns×2.6368.914 ns×1.0

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

julia> versioninfo()
Julia Version 1.11.6
Commit 9615af0f269 (2025-07-09 12:58 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)