Created
March 11, 2014 13:52
-
-
Save Xaerxess/9486043 to your computer and use it in GitHub Desktop.
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
testing for $col_count == 1 | |
Rate for-each for-c | |
for-each 2118644/s -- -40% | |
for-c 3521127/s 66% -- | |
---------------------------------------- | |
testing for $col_count == 2 | |
Rate for-each for-c | |
for-each 1923077/s -- -35% | |
for-c 2958580/s 54% -- | |
---------------------------------------- | |
testing for $col_count == 4 | |
Rate for-each for-c | |
for-each 1748252/s -- -12% | |
for-c 1976285/s 13% -- | |
---------------------------------------- | |
testing for $col_count == 8 | |
Rate for-c for-each | |
for-c 1308901/s -- -9% | |
for-each 1436782/s 10% -- | |
---------------------------------------- | |
testing for $col_count == 16 | |
Rate for-c for-each | |
for-c 737463/s -- -29% | |
for-each 1033058/s 40% -- | |
---------------------------------------- | |
testing for $col_count == 32 | |
Rate for-c for-each | |
for-c 408163/s -- -39% | |
for-each 672948/s 65% -- | |
---------------------------------------- | |
testing for $col_count == 64 | |
Rate for-c for-each | |
for-c 215332/s -- -45% | |
for-each 391543/s 82% -- | |
---------------------------------------- |
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
#!/usr/bin/perl | |
use v5.14; | |
use Benchmark qw(cmpthese); | |
for my $col_count (1, 2, 4, 8, 16, 32, 64) { | |
say "testing for \$col_count == $col_count"; | |
cmpthese( | |
5_000_000, | |
{ | |
'for-c' => sub { | |
for (my $col_index = 0 ; $col_index < $col_count ; $col_index++) { | |
} | |
}, | |
'for-each' => sub { | |
for my $col_index (0 .. $col_count - 1) { | |
} | |
}, | |
}); | |
say '-' x 40; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment