Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/bench.raku Secret

Created February 5, 2021 13:12
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 jnthn/742ffa9d1dce49186a7b524dce31436f to your computer and use it in GitHub Desktop.
Save jnthn/742ffa9d1dce49186a7b524dce31436f to your computer and use it in GitHub Desktop.
use nqp;
sub with-current-disp() {
my class C1 {
method m() { 'c1' }
}
my class C2 is C1 {
method m() { 'c2' ~ callsame() }
}
my class C3 is C2 {
method m() { 'c3' ~ callsame() }
}
my class C4 is C3 {
method m() { 'c4' ~ callsame() }
}
for ^1_000_000 {
C4.m
}
say "Current: " ~ now - ENTER now;
}
sub with-new-disp() {
my class C1 {
method m() { 'c1' }
}
my class C2 is C1 {
method m() { 'c2' ~ new-disp-callsame() }
}
my class C3 is C2 {
method m() { 'c3' ~ new-disp-callsame() }
}
my class C4 is C3 {
method m() { 'c4' ~ new-disp-callsame() }
}
for ^1_000_000 {
nqp::dispatch('raku-meth-call', C4, 'm', C4);
}
say "New: " ~ now - ENTER now;
}
with-current-disp();
with-new-disp();
Current: 42.794793
New: 6.3299149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment