[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: compgen is slow for large numbers of options

From: Chet Ramey
Subject: Re: compgen is slow for large numbers of options
Date: Mon, 19 Mar 2012 16:28:32 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 3/15/12 3:38 PM, Richard Neill wrote:
> Dear Bob,
> Thanks for your explanation. I do understand what is going on and why. But
> my point was that compgen has an implicit internal "grep" that is much less
> efficient than actual grep. Why is the performance of compgen's
> sorting/filtering algorithm so much worse than grep's ?
> Both of them start with a large list, and filter it to a small one.

Only by the most general of similarities.  In the first case, bash reads
300K through a pipe and stores it into a large string.  It then splits
the string into 50,000 words, expands each word using the shell word
expansions, then tests the expanded words for matches against a
particular string.  Grep reads a series of very short lines from stdin,
a line at a time, and matches each against a regexp.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]