There's more than one way to do things | |
PerlMonks |
Re: hashes in regexesby bjelli (Pilgrim) |
on Mar 29, 2001 at 05:26 UTC ( [id://68021]=note: print w/replies, xml ) | Need Help?? |
As a lowly acolyte I have great respect for <kbd>map</kbd> and a fondness of good old <kbd>foreach</kbd>. So I naturally thought: isn't a loop with simple pattens faster than a pattern with <kbd>|</kbd> in it? Here's my benchmarking code:
And the results: Benchmark: timing 500 iterations of many patterns, or pattern... many patterns: 2 wallclock secs ( 1.61 usr + 0.00 sys = 1.61 CPU) or pattern: 12 wallclock secs (11.94 usr + 0.01 sys = 11.95 CPU) Of course there's a difference in functionality between the two, just think of:
-- Brigitte 'I never met a chocolate I didnt like' Jellinek http://www.horus.com/~bjelli/ http://perlwelt.horus.at
In Section
Seekers of Perl Wisdom
|
|