Expand description
Sorting functions which don’t use optimizations based on the values of the keys. Useful for benchmarks and consistent performance.
For each digit (byte) of the key, radsort
reorders the slice once.
Functions in the crate root sort only by the bytes which differ between the
keys. This can lead to large differences in sorting time, based on the
values in the slice.
For example, sorting u32
all less than u8::MAX
will sort only by
the least significant byte and skip the three most significant bytes,
which are zero; this cuts the sorting time to roughly one quarter, plus
the overhead of analyzing the keys.
Unlike functions in the crate root, functions in this module don’t use this optimization and sort by all bytes of the key. This leads to worse but more consistent performance. The effects of the CPU cache will still play a role, but at least the number of executed instructions will not depend on the values in the slice, only on the length of the slice and the width of the key type.
Functions§
- Version of
sort
which does not skip digits (bytes). - Version of
sort_by_cached_key
which does not skip digits (bytes). - Version of
sort_by_key
which does not skip digits (bytes).