Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

Significant slowdown of multi-methods when the not-called one uses a "where" restriction. #5292

Open p6rt opened 8 years ago

p6rt commented 8 years ago

Migrated from rt.perl.org#128055 (status was 'new')

Searchable as RT128055$

p6rt commented 8 years ago

From calvin.schwenzfeier@gmail.com

From the #perl6 channel​:

cschwenz 8​:46 p6​: class Foo { multi method aaa() { my Int $y = 0; }; multi method aaa(Int $x = 1) { my Int $y = $x; }; }; my Instant $t1 = now; for (1 .. 10000) { Foo.aaa() }; my Instant $t2 = now; my $d1 = ( $t2 - $t1 ).narrow; say "$d1"; camelia 8​:46 rakudo-moar ef3e62​: OUTPUT«0.00490609␤»

cschwenz 8​:46 p6​: class Foo { multi method aaa() { my Int $y = 0; }; multi method aaa(Int $x where $x > 0 = 1) { my Int $y = $x; }; }; my Instant $t1 = now; for (1 .. 10000) { Foo.aaa() }; my Instant $t2 = now; my $d1 = ( $t2 - $t1 ).narrow; say "$d1"; camelia 8​:46 rakudo-moar ef3e62​: OUTPUT«0.31616794␤»

Of note, the "where" restriction is placed on the multi-method which is *not* called.

Hope that helps, ~Cal