Skip to content

Unexpected Performance Difference between / and \ #585

Open
@judober

Description

@judober

I noticed significant speed differences for left (\) and right(/) matrix division for 4 by 4 and bigger matrices. To my understanding, / is just mapped to \ and thus, I wouldn't expect these differences especially not / being faster than \. Does anyone know why this is happening?

julia> using StaticArrays, BenchmarkTools

julia> @benchmark a \ b setup = begin
                  a = rand(SMatrix{4, 4})
                  b = rand(SMatrix{4, 4})
              end
BenchmarkTools.Trial: 
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     232.326 ns (0.00% GC)
  median time:      234.532 ns (0.00% GC)
  mean time:        260.624 ns (0.00% GC)
  maximum time:     1.799 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     442

julia> @benchmark a / b setup = begin
                  a = rand(SMatrix{4, 4})
                  b = rand(SMatrix{4, 4})
              end
BenchmarkTools.Trial: 
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     183.468 ns (0.00% GC)
  median time:      184.085 ns (0.00% GC)
  mean time:        206.420 ns (0.00% GC)
  maximum time:     4.133 μs (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     681

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions