Random sampling in Phobos
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Tue Apr 17 16:11:09 PDT 2012
On 17/04/12 17:31, Andrei Alexandrescu wrote:
> This would be great, but you'd need to show with benchmarks that the proposed
> implementation does better than the extant one for most cases that matter.
OK, I've uploaded a prototype version in a GitHub repo:
git://github.com/WebDrake/RandomSample.git
This isn't a patch against Phobos, but a copy-paste and rename of the
RandomSample struct/randomSample functions that lets me do some side-by-side
comparison to current Phobos implementation. It does need a fully up-to-date
DMD, druntime and Phobos to compile.
I've put in place a handful of very simple tests just to give an idea of some of
the speed differences. The difference probably isn't so great for most trivial
use-cases, but if you're doing a LOT of sampling, or you're sampling from a very
large set of records, the difference becomes quite apparent.
I'm not sure what use-cases you have in mind for the benchmarks -- can you give
me some idea, so I can go ahead and implement them?
Thanks and best wishes,
-- Joe
More information about the Digitalmars-d
mailing list