Skip to content

Instantly share code, notes, and snippets.

@jnthn

jnthn/head.raku Secret

Created April 14, 2021 10:33
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/5b680295227394afda401623c61e2989 to your computer and use it in GitHub Desktop.
Save jnthn/5b680295227394afda401623c61e2989 to your computer and use it in GitHub Desktop.
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