Skip to content

Commit 7ca72c7

Browse files
authored
document :radixsort performance (#720)
1 parent 0e8e4aa commit 7ca72c7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/counts.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,14 @@ raw counts.
258258
- `:radixsort`: if `radixsort_safe(eltype(x)) == true` then use the
259259
[radix sort](https://en.wikipedia.org/wiki/Radix_sort)
260260
algorithm to sort the input vector which will generally lead to
261-
shorter running time. However the radix sort algorithm creates a
262-
copy of the input vector and hence uses more RAM. Choose `:dict`
263-
if the amount of available RAM is a limitation.
261+
shorter running time for large `x` with many duplicates. However
262+
the radix sort algorithm creates a copy of the input vector and
263+
hence uses more RAM. Choose `:dict` if the amount of available
264+
RAM is a limitation.
264265
265266
- `:dict`: use `Dict`-based method which is generally slower but uses less
266-
RAM and is safe for any data type.
267+
RAM, is safe for any data type, is faster for small arrays, and
268+
is faster when there are not many duplicates.
267269
"""
268270
addcounts!(cm::Dict, x; alg = :auto) = _addcounts!(eltype(x), cm, x, alg = alg)
269271

@@ -430,12 +432,14 @@ raw counts.
430432
- `:radixsort`: if `radixsort_safe(eltype(x)) == true` then use the
431433
[radix sort](https://en.wikipedia.org/wiki/Radix_sort)
432434
algorithm to sort the input vector which will generally lead to
433-
shorter running time. However the radix sort algorithm creates a
434-
copy of the input vector and hence uses more RAM. Choose `:dict`
435-
if the amount of available RAM is a limitation.
435+
shorter running time for large `x` with many duplicates. However
436+
the radix sort algorithm creates a copy of the input vector and
437+
hence uses more RAM. Choose `:dict` if the amount of available
438+
RAM is a limitation.
436439
437440
- `:dict`: use `Dict`-based method which is generally slower but uses less
438-
RAM and is safe for any data type.
441+
RAM, is safe for any data type, is faster for small arrays, and
442+
is faster when there are not many duplicates.
439443
"""
440444
countmap(x; alg = :auto) = addcounts!(Dict{eltype(x),Int}(), x; alg = alg)
441445
countmap(x::AbstractArray{T}, wv::AbstractVector{W}) where {T,W<:Real} = addcounts!(Dict{T,W}(), x, wv)

0 commit comments

Comments
 (0)