in reply to Re: grepping for
in thread grepping for
I benchmarked this using some sample data I made up and it is about %35 faster than the original version. Your performance may vary.my $dir='/acm/'; my $strlen=length ($dir) while (<LOG>) { my $url = (split())[6]; if ((substr($url,0,$strlen) eq $dir) && ($url=~/$error/)) { if (exists $report{$url}) { $report{$url}++; } else { $report{$url} = 1; } } }
Regular-expressions are slower than straight string operations. So if you can accomplish what you want with string operations and performance matters, then you can tune your code by replacing some regular-expressions with string operations (only feasible for simple regular-expressions).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: Re: grepping for
by jjhorner (Hermit) on May 12, 2000 at 21:38 UTC |