ranges
Ellery Newcomer
ellery-newcomer at utulsa.edu
Thu Apr 29 12:39:59 PDT 2010
Oh I get it. hasLength is broken.
http://d.puremagic.com/issues/show_bug.cgi?id=3508
Kyle Foley's patch brings my program to a more respectable 1.6 times
slower or thereabouts.
On 04/29/2010 01:52 PM, Ellery Newcomer wrote:
> Hello.
>
> I'm muddling over the following code, which compares an array/take
> composition with the analogous imperative code. For medium-large values
> of n, I'm seeing a fivefold degradation in performance, which blows up
> to 30 times worse at n=50000000.
>
> Any ideas on why this is or better ways to accomplish the same?
>
> import std.range;
> import std.date;
> import std.random;
> import std.array;
> import std.stdio;
>
> void main(){
> for(int n = 500; n <= 500000000; n *= 10){
> writeln(n);
> auto r = rndGen();
> auto tz = getUTCtime();
> auto a = new int[n];
> foreach(ref aa; a){
> aa = r.front();
> r.popFront();
> }
> auto tz2 = getUTCtime();
> auto a2 = array(take(r,n));
> auto tz3 = getUTCtime();
> writeln("\tarr: ",tz2-tz);
> writeln("\trange: ",tz3-tz2);
> }
> }
> ~
More information about the Digitalmars-d-learn
mailing list