Skip to content

sort! is very slow for SparseMatrixCSC #302

Open
@LilithHafner

Description

@LilithHafner
julia> x = sprand(10, .1)
10-element SparseVector{Float64, Int64} with 1 stored entry:
  [3 ]  =  0.850332

julia> sort!(x)
10-element SparseVector{Float64, Int64} with 8 stored entries:
  [3 ]  =  0.0
  [4 ]  =  0.0
  [5 ]  =  0.0
  [6 ]  =  0.0
  [7 ]  =  0.0
  [8 ]  =  0.0
  [9 ]  =  0.0
  [10]  =  0.850332

julia> @btime sort!(copy(x)) setup = (x = sprand(1000, .01));
  96.011 μs (4 allocations: 288 bytes)

julia> @btime sort(x) setup = (x = sprand(1000, .01));
  496.583 ns (8 allocations: 512 bytes)

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