Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~/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
- }
- })
Add Comment
Please, Sign In to add comment