Skip to content

Instantly share code, notes, and snippets.

@cam8001
Last active December 18, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cam8001/5817883 to your computer and use it in GitHub Desktop.
Save cam8001/5817883 to your computer and use it in GitHub Desktop.
Speed difference between GNU grep and OSX 10.8 BSD grep
$ grep --version
grep (BSD grep) 2.5.1-FreeBSD
$ ggrep --version
ggrep (GNU grep) 2.14
# Here it goes
$ time cat varnish_log_200_only.txt | ggrep -F 'www.some.url.gov' | wc -l
957979
real 0m27.424s
user 0m27.428s
sys 0m1.481s
$ time cat varnish_log_200_only.txt | grep -F 'www.some.url.gov' | wc -l
957979
real 0m58.179s
user 0m58.168s
sys 0m1.845s
@cam8001
Copy link
Author

cam8001 commented Jun 19, 2013

Also, gnu grep seems to cache results in some way or another, whereas bsd grep doesn't. Apparently this is happening at the filesystem level rather than in grep itself, but it doesn't seem to cache under bsd grep.

@cam8001
Copy link
Author

cam8001 commented Feb 3, 2014

Mavericks' grep version is unchanged from Mountain Lion:

$ uname -a && grep -V
Darwin kerbcrawler 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
grep (BSD grep) 2.5.1-FreeBSD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment