in reply to Craftier
and the results areuse Benchmark; my $junk = 'The quick brown fox Jumped over the lazy dog'; timethese(5000000, { 'split' => '$junk = join \' \',split $junk;', 'regex1' => '$junk =~ tr/\s//;', 'regex2' => '$junk =~ s/\s//g;', });
Benchmark: timing 5000000 iterations of regex1, regex2, split... regex1: 3 wallclock secs ( 4.38 usr + 0.00 sys = 4.38 CPU) @ 11 +42334.93/s (n=5000000) regex2: 3 wallclock secs ( 3.50 usr + 0.00 sys = 3.50 CPU) @ 14 +26940.64/s (n=5000000) split: 15 wallclock secs (15.07 usr + 0.00 sys = 15.07 CPU) @ 33 +1762.99/s (n=5000000)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Craftier
by chipmunk (Parson) on Dec 15, 2000 at 04:30 UTC | |
by snax (Hermit) on Dec 15, 2000 at 13:57 UTC | |
by chipmunk (Parson) on Dec 15, 2000 at 19:58 UTC | |
by BatGnat (Scribe) on Dec 15, 2000 at 06:49 UTC | |
by a (Friar) on Dec 15, 2000 at 09:31 UTC |