Created
June 20, 2014 09:33
-
-
Save marramgg/c93f4f7f34ebf7bcfd3d to your computer and use it in GitHub Desktop.
Benchmark unary increments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use warnings; | |
use strict; | |
use Benchmark qw( timethese ); | |
my ( $preinc, $postinc ) = ( 0, 0 ); | |
timethese(100_000_000, { | |
'use_preinc' => sub { ++$preinc; }, | |
'use_postinc' => sub { $postinc++; }, | |
}); |
Here's mine:
This is perl 5, version 20, subversion 0 (v5.20.0) built for darwin-thread-multi-2level
Benchmark: timing 100000000 iterations of use_postinc, use_preinc...
use_postinc: 3 wallclock secs ( 3.43 usr + 0.02 sys = 3.45 CPU) @ 28985507.25/s (n=100000000)
use_preinc: 2 wallclock secs ( 1.83 usr + 0.00 sys = 1.83 CPU) @ 54644808.74/s (n=100000000)
This is perl 5, version 20, subversion 0 (v5.20.0) built for x86_64-linux
Benchmark: timing 100000000 iterations of use_postinc, use_preinc...
use_postinc: 5 wallclock secs ( 5.96 usr + -0.01 sys = 5.95 CPU) @ 16806722.69/s (n=100000000)
use_preinc: 4 wallclock secs ( 3.87 usr + 0.00 sys = 3.87 CPU) @ 25839793.28/s (n=100000000)
Thanks guys :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My results:
Benchmark: timing 100000000 iterations of use_postinc, use_preinc...
use_postinc: 1 wallclock secs ( 1.50 usr + 0.01 sys = 1.51 CPU) @ 66225165.56/s (n=100000000)
use_preinc: 0 wallclock secs ( 1.22 usr + 0.00 sys = 1.22 CPU) @ 81967213.11/s (n=100000000)