in reply to convert whitespaces to underscores
use Benchmark qw( cmpthese ); cmpthese( 100_000, { 's' => sub { $a='a _ b __ c'; $a=~s/_+//g; }, 'y' => sub { $a='a _ b __ c'; $a=~ y/_//sd; } } ); __END__ Benchmark: timing 100000 iterations of s, y... s: 9 wallclock secs ( 7.18 usr + 0.00 sys = 7.18 CPU) @ 13 +927.58/s (n=100000) y: 2 wallclock secs ( 2.19 usr + 0.00 sys = 2.19 CPU) @ 45 +578.85/s (n=100000) Rate s y s 13928/s -- -69% y 45579/s 227% --
______crazyinsomniac_____________________________ Of all the things I've lost, I miss my mind the most. perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;" |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: (crazyinsomniac) Re: convert whitespaces to underscores
by Juerd (Abbot) on May 26, 2002 at 23:23 UTC |