Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/head.raku Secret

Created Apr 14, 2021
Embed
What would you like to do?
multi fallback(Any $x) { "a$x" }
multi fallback(Numeric $x) { "n" ~ callsame }
multi fallback(Real $x) { "r" ~ callsame }
multi fallback(Int $x) { "i" ~ callsame }
for ^1_000_000 {
fallback(4+2i);
fallback(4.2);
fallback(42);
}
say now - INIT now;
use nqp;
multi fallback(Any $x) { "a$x" }
multi fallback(Numeric $x) { "n" ~ new-disp-callsame }
multi fallback(Real $x) { "r" ~ new-disp-callsame }
multi fallback(Int $x) { "i" ~ new-disp-callsame }
for ^1_000_000 {
nqp::dispatch('raku-call', &fallback, 4+2i);
nqp::dispatch('raku-call', &fallback, 4.2);
nqp::dispatch('raku-call', &fallback, 42);
}
say now - INIT now;
jnthn@homedev:~/dev/rakudo$ ./rakudo-m bench-head.raku
31.307494412
jnthn@homedev:~/dev/rakudo$ RAKUDO_NEW_DISP=1 ./rakudo-m bench-new-disp.raku
11.467661091
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment