in reply to What is faster?
One situation where I might use an external grep utility in preference to the internal one is if the script produces large volumes of ouput, and the selection process filters out a large proportion of it. The difference in pure speed terms is likely to be minimal, but the reduction in memory usage by not loading data just to discard it might be worth having.
That said, the amount of memory used by the internal version could be minimised by applying the grep at input rather than afterwards. Ie.
Update: DO NOT USE THE CODE BELOW!! Good idea, bad implementation as pointed out below by tilly
open(OUTPUT, "$script |"); my @output = grep { EXPRESSION } <OUTPUT>;
You'd probably need to be discarding a significant amount of input for this to make any great difference, but it probably wouldn't harm in any case, so why not do it anyway.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What is faster?
by l2kashe (Deacon) on Jun 02, 2003 at 14:20 UTC | |
by bbfu (Curate) on Jun 03, 2003 at 01:44 UTC | |
by Not_a_Number (Prior) on Jun 02, 2003 at 18:16 UTC | |
by l2kashe (Deacon) on Jun 02, 2003 at 19:00 UTC | |
|
Re: Re: What is faster?
by tilly (Archbishop) on Jun 03, 2003 at 04:55 UTC | |
by BrowserUk (Patriarch) on Jun 03, 2003 at 06:00 UTC |