Faster sort?
Andrea Fontana via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 7 02:00:05 PDT 2016
On Thursday, 7 April 2016 at 08:53:32 UTC, Andrea Fontana wrote:
> On Thursday, 7 April 2016 at 08:41:51 UTC, John Colvin wrote:
>> *hench my example of compiling one module to an object file
>> and then compiling the other and linking them, without ever
>> importing one from the other.
>
> If i move boolSort() on another module but I can't use auto as
> return type.
> Return type is a "voldemort" type returned by std.range.chain.
>
> How can I define it?
What about this?
Duration total;
foreach(_; 0..10000)
{
auto arr = generate!( () => uniform(0,2)).map!(x =>
cast(bool)x).take(65536).array;
StopWatch sw;
sw.start;
auto t = boolSort(arr);
sw.stop;
size_t sum = 0;
foreach(x; t.map!(x => x?1:0)) sum+=x;
writeln(sum);
}
writeln(total);
This outputs:
32784
...
...
...
32819
32648
32649
32716
32972
0 hnsecs
More information about the Digitalmars-d
mailing list