Created
August 29, 2012 16:50
-
-
Save marcusramberg/3515534 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
~/Source/web_irc(branch:master*) » perl t.pl marcus@mrbook | |
Rate hack sprintf normal | |
hack 1488095/s -- -64% -80% | |
sprintf 4149378/s 179% -- -44% | |
normal 7407407/s 398% 79% -- | |
------------------------------------------------------------ | |
~/Source/web_irc(branch:master*) » cat t.pl marcus@mrbook | |
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use feature 'say'; | |
use Benchmark 'cmpthese'; | |
cmpthese(10000000, { | |
normal => sub { | |
my $res = 5 * 5; | |
"Result is: $res"; | |
}, | |
hack => sub { | |
my $res = 5 * 5; | |
"Result is: @{[$res]}" | |
}, | |
sprintf => sub { | |
my $res = 5 * 5; | |
sprintf "Result is: %s",$res | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hack => sub {
"Result is: @{[5 * 5]}"
},
join => sub {
join '', "Result is: ", 5 * 5;
},