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.475 ns8.030 ns×2.33.475 ns×1.0
A ⊡ a3.485 ns47.916 ns×14.03.485 ns×1.0
S ⊡ a3.835 ns48.108 ns×13.03.485 ns×0.91
Double contraction
A ⊡₂ A3.835 ns10.195 ns×2.73.825 ns×1.0
S ⊡₂ S3.825 ns9.102 ns×2.43.825 ns×1.0
AA ⊡₂ A8.552 ns68.207 ns×8.08.552 ns×1.0
SS ⊡₂ S4.386 ns60.784 ns×14.04.416 ns×1.0
Tensor product
a ⊗ a3.485 ns29.883 ns×8.63.825 ns×1.1
Cross product
a × a3.485 ns29.883 ns×8.63.825 ns×1.1
Determinant
det(A)3.825 ns179.296 ns×47.03.476 ns×0.91
det(S)3.475 ns175.237 ns×50.03.485 ns×1.0
Inverse
inv(A)6.480 ns421.638 ns×65.08.622 ns×1.3
inv(S)4.546 ns408.452 ns×90.08.621 ns×1.9
inv(AA)1.054 μs1.513 μs×1.41.054 μs×1.0
inv(SS)434.874 ns914.160 ns×2.1398.557 ns×0.92

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

julia> versioninfo()
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 4 × AMD EPYC 9V74 80-Core Processor
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, znver4)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)