You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is related to several comments in #201 and is an extension of the work done as part of #194.
In many cases sample_indicies can be a u32 or even a u16 (u8 is probably not worth it) to save on performance and memory usage. This applies to both the cache and inplace implementations. This ticket is to investigate what it would take to make the function generic.
This should not be (much of) a breaking change, since in most cases type inference would infer the usize requirement. However, it would be a potentially minor one.
The text was updated successfully, but these errors were encountered:
Using u32 in place of usize (aka u64) improves performance of the inplace impl significantly. Since this method is inappropriate for length > ~1e7 and u32 suffices up to ~4e9 I see no point having a u64 version.
Using u16 for inplace improves performance up to 3x in benchmarks (10 of 10'000 case) but normally much less than 2x, and sometimes worse. Since the algorithm is already quite fast for these representable lengths (around 10ms for length 10'000) I don't see a big incentive to investigate further (also, these benchmarks give some strange results).
The cache method appears to be about 10% faster using u32.
For completeness, I also tested Floyd's alg (#479) with u32, and it is around 3-15% faster.
For conciseness, I think the best approach is to make the inplace method use u32 only and keep the other methods using usize (since the latter are both applicable to sample a small "amount" from a huge range; that said I'm not sure how often they would be used for this).
Note that I don't think generics are a great option here, since users will often use usize even with ranges.
This is related to several comments in #201 and is an extension of the work done as part of #194.
In many cases
sample_indicies
can be au32
or even au16
(u8
is probably not worth it) to save on performance and memory usage. This applies to both thecache
andinplace
implementations. This ticket is to investigate what it would take to make the function generic.This should not be (much of) a breaking change, since in most cases type inference would infer the
usize
requirement. However, it would be a potentially minor one.The text was updated successfully, but these errors were encountered: