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.276 ns×3.33.095 ns×1.1
A ⊡ a3.406 ns53.776 ns×16.03.406 ns×1.0
S ⊡ a3.406 ns53.755 ns×16.03.406 ns×1.0
Double contraction
A ⊡₂ A3.706 ns11.121 ns×3.03.406 ns×0.92
S ⊡₂ S3.095 ns10.198 ns×3.33.406 ns×1.1
AA ⊡₂ A7.733 ns72.356 ns×9.47.742 ns×1.0
SS ⊡₂ S4.087 ns67.801 ns×17.04.088 ns×1.0
Tensor product
a ⊗ a3.406 ns33.193 ns×9.73.716 ns×1.1
Cross product
a × a3.406 ns33.193 ns×9.73.716 ns×1.1
Determinant
det(A)3.406 ns170.157 ns×50.03.095 ns×0.91
det(S)3.396 ns173.630 ns×51.03.095 ns×0.91
Inverse
inv(A)6.191 ns478.379 ns×77.07.410 ns×1.2
inv(S)4.939 ns487.768 ns×99.07.410 ns×1.5
inv(AA)957.524 ns1.493 μs×1.6949.545 ns×0.99
inv(SS)368.855 ns954.312 ns×2.6364.555 ns×0.99

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)