in reply to Re: Difference between tr// and s///?
in thread Difference between tr/// and s///?
Rate transliterate substitution transliterate 1011345/s -- -49% substitution 1969797/s 95% --
Now we have the same string for the benchmark tests! And the results are as expected:use Benchmark qw(:all); $toto = 'this+is+my+text+and+here+is+more+and+more+this+is+my+text+and ++here+is+more+and+more+this+is+my+text+and+here+is+more+and+more'; $count =-5; $results = timethese($count, { 'transliterate' => sub { $toto = 'this+is+my+text+and+ +here+is+more+and+more+this+is+my+text+and+here+is+more+and+more+this+ +is+my+text+and+here+is+more+and+more'; $toto =~tr/+/ /; }, 'substitution' => sub { $toto = 'this+is+my+text+and+h +ere+is+more+and+more+this+is+my+text+and+here+is+more+and+more+this+i +s+my+text+and+here+is+more+and+more'; $toto =~s/\+/ /g; }, }, 'none' ); cmpthese( $results ) ; exit 0;
Rate substitution transliterate substitution 73807/s -- -88% transliterate 625256/s 747% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Difference between tr// and s///?
by Sol-Invictus (Scribe) on Feb 06, 2004 at 16:29 UTC | |
by HyperZonk (Friar) on Feb 06, 2004 at 16:32 UTC |