On Sat, 06 Jun 2015 20:24:32 -0700, r...@hoelz.ro wrote:
> Let's say I have an array where @array.end == $end.  Using
> @array[0..$end] is about 20 times faster than @array[0..*].  I have
> attached an example script that demonstrates this.


Thanks for the report, however there's no issue with the compiler here.

You're comparing different behaviours: 0..* is a lazy Iterable, so extra checks
are performed to stop iteration of indices once an end is reached. If you make 
0..$end lazy,
so the same checks are performed, the perf difference actually gives 0..* is 
small edge (likely due
to optimized Ranger.iterator)

<Zoffix__> m: my @array = 1..1000; my $end = @array.end; for ^500 { $ = 
@array[0..*] }; say now - INIT now
<camelia> rakudo-moar 39d50a: OUTPUT: «3.050471␤»
<Zoffix__> m: my @array = 1..1000; my $end = @array.end; for ^500 { $ = 
@array[lazy 0..$end] }; say now - INIT now
<camelia> rakudo-moar 39d50a: OUTPUT: «3.3454447␤»

Reply via email to