[comp.unix.misc] Fgrep need not be slow

jtc@van-bc.wimsey.bc.ca (J.T. Conklin) (10/08/90)

In article <3790@awdprime.UUCP> tif@doorstop.austin.ibm.com (Paul Chamberlain) writes:
>Fgrep means Fixed, egrep means Exponential (like in Exponentially faster)!
>If you care one tiny bit about the speed you'll only use fgrep when you
>have to.  Now can we stop discussing the fastest way to use fgrep?
>
>This lesson is a review for those that didn't believe it the first time.

As has been mentioned before, it depends on your implementation: not
all fgreps are slow.

I compared the speeds of GNU fgrep, GNU egrep, SCO XENIX fgrep, and SCO
XENIX egrep by searching for the word "dictionary" in a file containing
fourty-two copies of /usr/dict/words.

Execution speeds were as follows:
	GNU fgrep	10s
	GNU egrep	11s
	SCO egrep	16s
	SCO fgrep	59s

    --jtc

-- 
J.T. Conklin	UniFax Communications Inc.
		...!{uunet,ubc-cs}!van-bc!jtc, jtc@wimsey.bc.ca

tif@doorstop.austin.ibm.com (Paul Chamberlain) (10/09/90)

In article <2440@van-bc.wimsey.bc.ca> jtc@van-bc.wimsey.bc.ca (J.T. Conklin) writes:
>In article <3790@awdprime.UUCP> tif@doorstop.austin.ibm.com (Paul Chamberlain) writes:
>>Fgrep means Fixed, egrep means Exponential (like in Exponentially faster)!
>As has been mentioned before, it depends on your implementation: not
>all fgreps are slow.

I confess, my statement was based just on SCO XENIX although I have been
led to believe than SysV also acted this way.  I just tried two AIX's.
AIX V2.2.1 fgrep is only slightly slower than egrep, and AIX V3.1 fgrep
is slightly faster than egrep!

Paul Chamberlain | I do NOT represent IBM.     tif@doorstop, sc30661 at ausvm6
512/838-7008     | ...!cs.utexas.edu!ibmaus!auschs!doorstop.austin.ibm.com!tif

greg@tcnz2.tcnz.co.nz (Greg Calkin) (10/10/90)

In article jtc@van-bc.wimsey.bc.ca (J.T. Conklin) writes:
>In article tif@doorstop.austin.ibm.com (Paul Chamberlain) writes:
>>Fgrep means Fixed, egrep means Exponential (like in Exponentially faster)!
>>If you care one tiny bit about the speed you'll only use fgrep when you
>>have to.  Now can we stop discussing the fastest way to use fgrep?
>>
>>This lesson is a review for those that didn't believe it the first time.
>
>As has been mentioned before, it depends on your implementation: not
>all fgreps are slow.

Quite correct - in the NCR tower documentation,  you get

An eqrep pattern is a full regular expression; egrep uses a fast
deterministic algorithm that sometimes needs exponential space. Fgrep
patterns are fixed strings; fgrep is fast and compact.

My testing in the past has born this out - for simple tasks, fgrep is much
quicker.

So, this lesson is a review for those that believe that all Unixes are the
same. RTFM and experiment.

-- 
Greg Calkin, Systems Engineer {include "sexual_hard_sell"}   (greg@tcnz.co.nz)
Thomas Cook N.Z. Limited, PO Box 24, Auckland CPO, New Zealand, Ph (09)-793920
Disclaimer : Would you buy a used car from someone with these opinions ?