Benchmark results
- Dominant language
- Perl
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Not really an *issue*, but thought I'd send you these.
Benchmark source
```
use v5.16;
use warnings;
use Benchmark 'cmpthese';
use Test::More;
package SMT::test {
use Sub::Multi::Tiny qw( $foo $bar );
sub first :M($foo, $bar) {
return $foo ** $bar;
}
sub second :M($foo) {
return $foo + 42;
}
}
package M {
use Kavorka qw(multi fun);
multi fun test ($foo, $bar) {
return $foo ** $bar;
}
multi fun test ($foo) {
return $foo + 42;
}
}
is(M::test(8,2), 64);
is(M::test(3,3), 27);
is(M::test(58), 100);
is(SMT::test(8,2), 64);
is(SMT::test(3,3), 27);
is(SMT::test(58), 100);
cmpthese -1, {
M => q{ M::test(3,3); SMT::test(0); },
SMT => q{ SMT::test(3,3); SMT::test(0); },
};
```
Results on my laptop:
```
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
Rate SMT M
SMT 255999/s -- -11%
M 286959/s 12% --
```
I had expected a bit of a slow down from your use of guards and global variables, but it actually performs at a pretty decent rate.
As you use a stringy eval to build your dispatcher, you could probably speed things up a little by avoiding the hashtable arity lookup thing at run time, and putting `if(@_==1) {...} elsif(@_==2) {...}` into the evaluated string itself. The only advantage in keeping the hash table lookup would be if you wanted to be able to insert new entries into it at run-time, but right now the hash is a lexical variable, so short of some PadWalker tricks, can't be altered by runtime code anyway.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.