Someone wanted me to test if it work to speed up the multiplication by 10 to add the string ‘0’ to the end:
1 2 3 4 5 6 7 8 9 10 11 12 |
#!/usr/bin/perl use strict; use Benchmark qw(:all) ; my $a = 100; my $x = 100; print "".($a * 10)."\n"; print "".($a . '0')."\n"; cmpthese(-2, { 'mul' => sub {$x = $a * 10;}, 'con' => sub {$x = $a . '0';}, }); |
Our result:
1 2 3 4 5 |
1000 1000 Rate con mul con 10268075/s -- -58% mul 24702018/s 141% -- |
It was not a very good idea because its very slow …. better use the normal way.
After checking out a handful of the blog articles
on your website, I seriously appreciate your way of writing a blog.
I saved as a favorite it to my bookmark site list and will be checking
back in the near future. Please visit my website too and let me know your
opinion.
Thanks a bunch for sharing this with all of us you really know what you’re
speaking about! Bookmarked. Kindly additionally discuss with my site
=). We could have a hyperlink alternate agreement between us