Guest User

Untitled

a guest
Dec 12th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. ~/Source/web_irc(branch:master*) » perl t.pl marcus@mrbook
  2. Rate hack sprintf normal
  3. hack 1488095/s -- -64% -80%
  4. sprintf 4149378/s 179% -- -44%
  5. normal 7407407/s 398% 79% --
  6. ------------------------------------------------------------
  7. ~/Source/web_irc(branch:master*) » cat t.pl marcus@mrbook
  8. #!/usr/bin/perl
  9.  
  10. use strict;
  11. use warnings;
  12. use feature 'say';
  13. use Benchmark 'cmpthese';
  14.  
  15. cmpthese(10000000, {
  16. normal => sub {
  17. my $res = 5 * 5;
  18. "Result is: $res";
  19. },
  20. hack => sub {
  21. my $res = 5 * 5;
  22. "Result is: @{[$res]}"
  23. },
  24. sprintf => sub {
  25. my $res = 5 * 5;
  26. sprintf "Result is: %s",$res
  27. }
  28. })
Add Comment
Please, Sign In to add comment