Created
October 3, 2018 08:54
-
-
Save lizmat/4594bf4ae699b1464aa78ad49bb37220 to your computer and use it in GitHub Desktop.
Fastest Perl 6 object creation bench:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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