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.33.396 ns×1.2
A ⊡ a3.406 ns57.057 ns×17.03.406 ns×1.0
S ⊡ a3.406 ns58.024 ns×17.03.406 ns×1.0
Double contraction
A ⊡₂ A3.706 ns11.111 ns×3.03.096 ns×0.84
S ⊡₂ S3.095 ns10.188 ns×3.33.115 ns×1.0
AA ⊡₂ A7.732 ns83.732 ns×11.07.722 ns×1.0
SS ⊡₂ S4.077 ns72.728 ns×18.04.037 ns×0.99
Tensor product
a ⊗ a3.406 ns33.029 ns×9.73.406 ns×1.0
Cross product
a × a3.406 ns33.029 ns×9.73.406 ns×1.0
Determinant
det(A)3.406 ns168.261 ns×49.03.406 ns×1.0
det(S)3.396 ns171.386 ns×50.03.406 ns×1.0
Inverse
inv(A)6.252 ns470.724 ns×75.07.400 ns×1.2
inv(S)4.949 ns491.175 ns×99.07.400 ns×1.5
inv(AA)962.889 ns1.582 μs×1.6951.263 ns×0.99
inv(SS)366.655 ns1.015 μs×2.8355.498 ns×0.97

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

julia> versioninfo()
Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 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)