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 ns8.955 ns×3.23.095 ns×1.1
A ⊡ a3.406 ns49.028 ns×14.03.095 ns×0.91
S ⊡ a3.105 ns49.050 ns×16.03.095 ns×1.0
Double contraction
A ⊡₂ A3.406 ns10.811 ns×3.23.707 ns×1.1
S ⊡₂ S3.406 ns9.878 ns×2.93.707 ns×1.1
AA ⊡₂ A7.722 ns67.442 ns×8.77.732 ns×1.0
SS ⊡₂ S4.137 ns58.972 ns×14.04.067 ns×0.98
Tensor product
a ⊗ a3.105 ns28.093 ns×9.03.105 ns×1.0
Cross product
a × a3.105 ns28.093 ns×9.03.105 ns×1.0
Determinant
det(A)3.095 ns165.145 ns×53.03.406 ns×1.1
det(S)3.095 ns165.250 ns×53.03.406 ns×1.1
Inverse
inv(A)6.201 ns434.601 ns×70.07.582 ns×1.2
inv(S)4.949 ns437.227 ns×88.07.401 ns×1.5
inv(AA)988.286 ns1.522 μs×1.5972.500 ns×0.98
inv(SS)386.635 ns933.316 ns×2.4368.790 ns×0.95

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

julia> versioninfo()
Julia Version 1.12.5
Commit 5fe89b8ddc1 (2026-02-09 16:05 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-18.1.7 (ORCJIT, znver3)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)