Skip to content
Grep 2G source code in 0.23 second.
C# C Other
Find file
Latest commit 67133da Apr 9, 2016 @baohaojun tools/beagrep: from system-config
tools/mkbeagrepidx: from system-config

Signed-off-by: Bao Haojun <baohaojun@gmail.com>
Failed to load latest commit information.
BeagrepClient BeagrepClient/Snippet.cs: from beagle Jan 13, 2016
Filters Filters/FilterText.cs: add .jar file support Feb 16, 2016
Util BeagrepClient/Snippet.cs: from beagle Jan 13, 2016
beagrepd beagrepd/Makefile.am: make everything into bin, not sbin Feb 10, 2016
conf-data Remove dependency on python and X Sep 17, 2012
debian make it sign Feb 1, 2016
doc Rename refactory from beagle to beagrep Jan 10, 2012
glue add glib into glue Apr 5, 2015
tools tools/beagrep: from system-config Apr 9, 2016
.gitignore Ignore auto generated file. Sep 24, 2013
AUTHORS Able to build .deb package now, using ./debian/rules binary Jan 26, 2012
COPYING Rename refactory from beagle to beagrep Jan 10, 2012
ChangeLog Rename refactory from beagle to beagrep Jan 10, 2012
HACKING Update the readme Dec 24, 2012
Makefile.am Rename refactory from beagle to beagrep Jan 10, 2012
NEWS Minor editing of the auxiliary files. Jan 10, 2012
README Fix building error: README is required by autotools Oct 23, 2013
README.org Fix doc Oct 8, 2013
acinclude.m4 init from http://archive.ubuntu.com/ubuntu/pool/universe/b/beagle/bea… Oct 19, 2011
autogen.sh Rename refactory from beagle to beagrep Jan 10, 2012
beagrep-0.0.pc.in Rename refactory from beagle to beagrep Jan 10, 2012
beagrep-daemon.pc.in Rename refactory from beagle to beagrep Jan 10, 2012
beagrep-ui-0.0.pc.in Rename refactory from beagle to beagrep Jan 10, 2012
beagrep.spec.in Rename refactory from beagle to beagrep Jan 10, 2012
configure.in Util/Config.cs: fix mono upgrade Jan 4, 2016

README.org

beagrep

Grep 2G source tree in 0.23 seconds. A speed up of more than 10 fold.

It uses a search engine before using grep. The search engine is beagle, thus the name beagrep.

For more details, visit my github page (man page included).

How does it compare to ag

Ag (AKA the silver searcher) claims to be very fast, beating ack and GNU grep.

I compared ag and beagrep on my laptop:

ModelCPUMemory
Thinkpad T420Intel(R) Core(TM) i5-2520M CPU @ 2.50GHz8G

ag speed

    cd ~/src/android   

# One nice thing about ag is that it filters 
# VCS and binary files automatically.
    time ag readlink . 

The first time it took 3 minutes, the second time it took 8 seconds, very impressive! I think if I had learned about it earlier I probably wouldn’t have started working on beagrep in the first place, because I would have thought it is quick enough already.

beagrep speed

time beagrep -e readlink

The first time it took 30 seconds, the second time it took 0.42 second.

Another test is done on Linux kernel source code, where ag takes 1m35s/1.8s for cache hot/cold, while beagrep takes 15s/0.25s respectively.

(The claim that it took 0.23 second to grep 2G Android source code is achieved on my Dell Optiplex 960).

Pros and cons of beagrep

Pros

  • Very fast
  • Output format compatibility with grep, so it can be used by, for e.g., Emacs grep-mode directly.
  • Match not only file content, file names too, like locate(1).

Cons

  • You need build the search engine database beforehand (the first time you do this will take a long while, but subsequent updating is reasonably fast)
  • Works on whole words only: can not use partial word (beagrep -e readli) to find readlink.

Other grep like tools

Ack’s author Andy Lester has written a nice intro about all kinds of tools for searching source code.

Of particular interest to beagrep is Google’s Code Search tool.

To-do

  • Push beagrep into Debian distribution.

Acknowledgment

Thank the Beagle project for making the original engine. And of course, the Apache Lucene project.

Thank LDD’s author for saying “(LDD) is the result of hours of grepping” and getting me hooked to grep forever.

Last but not least, I submitted this README on reddit, and has refined it several times according to the comments there. To those who commented: thanks, I have learned from you!

Something went wrong with that request. Please try again.