Advertisement
Guest User

AutoRegexBenchmark

a guest
Mar 14th, 2016
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.53 KB | None | 0 0
  1. use Benchmark qw/cmpthese/;
  2. use Data::Dumper;
  3.  
  4. my @set= qw (123456  677  233  10000  11000  30  1  200
  5.                       120007  12  350  440  55 55  84213  999999  
  6.                       300000  1000000  2500000  400000000  
  7.                       22  0  1000  82468  7305 5  880000  10002000
  8.                       111  8990  578901  9999999  7777);
  9.  
  10. cmpthese(-10,{
  11.   regex2=> sub {
  12.       grep { /\b\d{1,6}\b/g}  @set ;
  13.   },
  14.   regex1=> sub {
  15.           grep { /(?<= )\w\w?+\w?+\w?+\w?+\w?+(?= )|123456/g}  @set ;
  16.   }
  17. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement