Perl-Sensitive Sunglasses | |
PerlMonks |
Re: Re: Hypergeometric Probability Calculation (speeding up 'choose' )by tilly (Archbishop) |
on Dec 05, 2003 at 16:50 UTC ( [id://312553]=note: print w/replies, xml ) | Need Help?? |
I just peeked in Math::Big. The factorial implementation is very slow. You should find a significant performance improvement with: (Incremental improvements over that are easily achieved as well.) I'll submit the suggestion to the maintainer. UPDATE: I remember the overload interface being slower on old Perl's, but on my machine (5.8.0) it seems marginally faster. So I replaced: with
UPDATE 2: Out of curiousity I wondered how the above Perl would compare with Ruby: This ran about 10x faster than Perl. Of course a naive factorial implementation in Ruby runs several times as fast as the smart one does in Perl. The difference is mainly what we get for all of the layers of getting around variables autoconverting themselves inappropriately for large integers. If you want to work with large integers, Perl is not the language to do it with.
In Section
Seekers of Perl Wisdom
|
|