in reply to Comparing Regular Expressions
This oneliner just runs your two regexps on the same text for a specific number of loop runs. Use a number which takes at least 10, better more, seconds for each loop.perl -le '$text = <STDIN>; $T=time; $TestText=$text; for (1..$ARGV[0]) + { $text =~ s/\s+,\s+|\s+,|,\s+/,/g; } print time - $T; $T=time; $Tes +tText=$text; for (1..$ARGV[0]) { $text =~ s/\s*,\s*/,/g; } print time + - $T;' 1000000 </tmp/text.file
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing Regular Expressions
by JavaFan (Canon) on Sep 01, 2009 at 00:31 UTC | |
by Sewi (Friar) on Sep 01, 2009 at 07:13 UTC |