Created
October 1, 2016 12:43
-
-
Save zoffixznet/f2e97446c4327916e51a3556c903972e to your computer and use it in GitHub Desktop.
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
use lib '/home/zoffix/CPANPRC/rakudo/bug'; | |
use nqp; | |
# use Foo; | |
use Test; | |
use MONKEY-TYPING; | |
augment class Array { | |
multi method foo1 (Int:D $o, Whatever $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Int:D $o, Callable:D $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Int:D $o, Int:D $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Whatever $o, Whatever $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Whatever $o, Callable:D $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Whatever $o, Int:D $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Callable:D $o, Whatever $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Callable:D $o, Callable:D $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 (Callable:D $o, Int:D $x, **@a) { self.foo1: $o, $x, @a } | |
multi method foo1 () {} | |
multi method foo1 (Whatever) {} | |
multi method foo1 (Callable:D $offset) {} | |
multi method foo1 (Int:D $offset) {} | |
multi method foo1 (Whatever, Whatever) {} | |
multi method foo1 (Whatever, Int:D $size) {} | |
multi method foo1 (Callable:D $offset, Callable:D $size) {} | |
multi method foo1 (Callable:D $offset, Whatever) {} | |
multi method foo1 (Callable:D $offset, Int:D $size) {} | |
multi method foo1 (Int:D $offset, Whatever) {} | |
multi method foo1 (Int:D $offset, Callable:D $size) {} | |
multi method foo1 (Int:D $offset, Int:D $size) {} | |
multi method foo1 ($offset, Whatever $size, **@new) {} | |
multi method foo1 ($offset, Callable:D $size, **@new) {} | |
multi method foo1 ($offset, Int:D $size, **@new) {} | |
multi method foo1 (Whatever, Whatever, @new) {} | |
multi method foo1 (Whatever, Int:D $size, @new) {} | |
multi method foo1 (Callable:D $offset, Callable:D $size, @new) {} | |
multi method foo1 (Callable:D $offset, Whatever, @new) {} | |
multi method foo1 (Callable:D $offset, Int:D $size, @new) {} | |
multi method foo2 ($x, $y, **@a) { | |
given self.^lookup('foo2').cando( \($x, $y, @a) )[0] { | |
.signature eqv &?BLOCK.signature and die; | |
$_($x, $y, @a); | |
} | |
} | |
multi method foo2 () {} | |
multi method foo2 (Whatever) {} | |
multi method foo2 (Callable:D $offset) {} | |
multi method foo2 (Int:D $offset) {} | |
multi method foo2 (Whatever, Whatever) {} | |
multi method foo2 (Whatever, Int:D $size) {} | |
multi method foo2 (Callable:D $offset, Callable:D $size) {} | |
multi method foo2 (Callable:D $offset, Whatever) {} | |
multi method foo2 (Callable:D $offset, Int:D $size) {} | |
multi method foo2 (Int:D $offset, Whatever) {} | |
multi method foo2 (Int:D $offset, Callable:D $size) {} | |
multi method foo2 (Int:D $offset, Int:D $size) {} | |
multi method foo2 ($offset, Whatever $size, **@new) {} | |
multi method foo2 ($offset, Callable:D $size, **@new) {} | |
multi method foo2 ($offset, Int:D $size, **@new) {} | |
multi method foo2 (Whatever, Whatever, @new) {} | |
multi method foo2 (Whatever, Int:D $size, @new) {} | |
multi method foo2 (Callable:D $offset, Callable:D $size, @new) {} | |
multi method foo2 (Callable:D $offset, Whatever, @new) {} | |
multi method foo2 (Callable:D $offset, Int:D $size, @new) {} | |
} | |
sub timethese ($n, %what) { | |
my %results; | |
for %what.kv -> $name, &code { | |
my $start = now; | |
code for ^$n; | |
%results{$name} = now - $start; | |
} | |
%results; | |
} | |
say "starting"; | |
my %res = timethese 10, { | |
before => &before, | |
after => &after, | |
}; | |
say "Before: %res<before>"; | |
say " After: %res<after>"; | |
printf " Diff: %.2f%%\n", | |
100*(%res<before> - %res<after>) / max(%res<before>,%res<after>); | |
sub before { | |
[].foo1: 0, 42, 1, 2, 3; | |
} | |
sub after { | |
[].foo2: 0, 42, 1, 2, 3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment