Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created October 3, 2018 08:54
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 lizmat/4594bf4ae699b1464aa78ad49bb37220 to your computer and use it in GitHub Desktop.
Save lizmat/4594bf4ae699b1464aa78ad49bb37220 to your computer and use it in GitHub Desktop.
Fastest Perl 6 object creation bench:
class Point {
has int $.x;
has int $.y;
method !SET($!x,$!y) { self }
method new(:$x is raw, :$y is raw) { self.CREATE!SET($x,$y) }
}
my $total = 0;
for ^1_000_000 -> int $_ {
my $p := Point.new(x => 2, y => 3);
$total += $p.x + $p.y;
}
say $total;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment