Created
November 18, 2008 21:46
-
-
Save tene/26291 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
[sweeks@kweh ~]$ perl slasho.pl | |
Rate without with | |
without 1468429/s -- -4% | |
with 1536098/s 5% -- |
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 Benchmark qw(:all :hireswallclock); | |
my $var = 'text'; | |
cmpthese( 10000000, { | |
without => sub { | |
my $x = 'omg text lol'; | |
$x =~ s/$var/wtf/; | |
}, | |
with => sub { | |
my $x = 'omg text lol'; | |
$x =~ s/$var/wtf/o; | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment