Random Utils
This repository contains an API to quickly extract random values from a source array.
This API aims to be scalable (i.e. does not depend on source array size), fair and returns a random array without duplicate.
Metrics
Expectations
- a source array of 1 000 000 elements
- a random sub-array of 100 000 elements
Elapsed time
- noob version (filter input array with split and join) ≈ 4 minutes
- smart version (in-place push back picked up elements) ≈ 25 seconds
- smarter version (in-place push back picked up elements and hash-based duplicates detection) ≈ 40 milliseconds