Perl bignum Benchmark

This is a Benchmark in Perl about bignum :

use Benchmark qw(:all) ;

cmpthese(-1, {
'dev'      => sub {my($x,$y) = (4,3); $x = $x/$y;},
'bignum'   => sub {my($x,$y) = (4,3); use bignum; $x = $x/$y;},
});

Our result:

            Rate    dev bignum 
dev    4670926/s     --   -11% 
bignum 5224717/s    12%     --

We see the cost is about 12% performance, so if its not really necessary we should tun this feature off.

2 thoughts on “Perl bignum Benchmark”

  1. Pretty nice post. I just stumbled upon your blog
    and wanted to say that I have truly enjoyed surfing around your blog posts.
    After all I will be subscribing to your rss feed and I hope you write again very soon!

Leave a Reply

Your email address will not be published.

4 × 2 =