Skip to content

Instantly share code, notes, and snippets.

@salortiz

salortiz/2015.12 Secret

Last active March 10, 2016 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salortiz/4ef300b4d7f2e9738024 to your computer and use it in GitHub Desktop.
Save salortiz/4ef300b4d7f2e9738024 to your computer and use it in GitHub Desktop.
Slurpy Buf.list
$ perl6 -v
This is Rakudo version 2015.12 built on MoarVM version 2015.12
implementing Perl 6.c.
[sog@monica Blob]$ perl6 bench.pl6
Benchmark:
Timing 1000 iterations of list, passli...
list: 1.2851 wallclock secs @ 778.1340/s (n=1000)
passli: 1.3605 wallclock secs @ 735.0190/s (n=1000)
$ perl6 -v
This is Rakudo version 2016.02-27-g2afe79f built on MoarVM version 2016.02
implementing Perl 6.c.
[sog@monica Blob]$ perl6 bench.pl6
Benchmark:
Timing 1000 iterations of list, passli...
list: 1.4013 wallclock secs @ 713.6286/s (n=1000)
passli: 1.6245 wallclock secs @ 615.5784/s (n=1000)
use v6;
use Bench;
my $b = Bench.new;
my $buf = Buf.new(0 xx 1000);
#multi sub foo(@vals) { @vals.elems };
#multi sub foo(*@vals) { foo(@vals) };
sub foo(*@vals) { @vals.elems };
$b.timethese(1000, {
list => { my @li = $buf.list; foo(@li); },
passli => { foo($buf.list) },
});
$ perl6 -v
This is Rakudo version 2016.02-30-gf25d41c built on MoarVM version 2016.02
implementing Perl 6.c.
[sog@monica Blob]$ perl6 bench.pl6
Benchmark:
Timing 1000 iterations of list, passli...
list: 1.2354 wallclock secs @ 809.4610/s (n=1000)
passli: 26.6272 wallclock secs @ 37.5556/s (n=1000)
$ perl6 -v
This is Rakudo version 2016.02-100-g4a0ba74 built on MoarVM version 2016.02-8-ga329e2d
implementing Perl 6.c.
[sog@monica Blob]$ perl6 bench.pl6
Benchmark:
Timing 1000 iterations of list, passli...
list: 1.2906 wallclock secs @ 774.8104/s (n=1000)
passli: 28.7112 wallclock secs @ 34.8296/s (n=1000)
@salortiz
Copy link
Author

The real problem isn't the change in Blob/Buf.list, but the really bad interactions between an Interator / Seq vs an slurpy argument, as proved by uncommenting the multis in bench.pl above.

So the solution to the original issue (creating a CArray from a Buf) can be solved adding a non slurpy candidate CArray.new(@vals)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment