Benchmarks

The CI-generated table below compares common small-tensor operations for Tensor, Array, and SArray. It is meant to show that Tensorial stays in the same small-tensor performance range as SArray while working directly with tensor types.

For fourth-order tensor baselines, the Array and SArray implementations use the classical Voigt form so that symmetries are handled correctly. Tensorial performs the same operations on tensor types directly, without manually converting formulas to 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.396 ns×1.2
A ⊡ a3.095 ns49.739 ns×16.03.396 ns×1.1
S ⊡ a3.096 ns49.556 ns×16.03.396 ns×1.1
Double contraction
A ⊡₂ A3.706 ns10.800 ns×2.93.396 ns×0.92
S ⊡₂ S3.396 ns9.878 ns×2.93.396 ns×1.0
AA ⊡₂ A7.752 ns68.344 ns×8.87.722 ns×1.0
SS ⊡₂ S4.097 ns59.408 ns×15.04.217 ns×1.0
Tensor product
a ⊗ a3.406 ns28.203 ns×8.33.406 ns×1.0
Cross product
a × a3.396 ns15.028 ns×4.43.095 ns×0.91
Determinant
det(A)3.095 ns162.031 ns×52.03.095 ns×1.0
det(S)3.396 ns170.035 ns×50.03.095 ns×0.91
Inverse
inv(A)6.241 ns435.005 ns×70.07.410 ns×1.2
inv(S)4.879 ns464.337 ns×95.07.410 ns×1.5
inv(AA)976.812 ns1.550 μs×1.6971.833 ns×0.99
inv(SS)386.187 ns979.091 ns×2.5364.515 ns×0.94

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 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)