なっく日報

技術やら生活やらのメモ

grep的なツール2016

超雑なエントリですが、書キノコしておきます。

grepするのに

普段はgrep的なコマンドとして、agを使っています。
GitHub - ggreer/the_silver_searcher: A code-searching tool similar to ack, but faster.

最近、v2にバージョンアップして、高速になったptも試したりしました。
https://github.com/monochromegane/the_platinum_searcher

が、そこまで乗り換えのメリットを感じなかったので、agを使いつづけてました。

まだまだあった

そんな折、2つほどgrep的なツールがあるとの情報を仕入れました。

github.com

github.com

試してみた

highwayをインストール

brew tap tkengo/highway
brew install highway

ちなみにコマンドはhw

siftをインストール

brew install sift

いろいろ実行

厳密かは知らんし、オプションも完全に一致しているかはちゃんと見ていないので参考程度に。

❯ find . -type f|wc -l
    3232

❯ time hw --no-group --no-color function
hw --no-group --no-color function  0.22s user 0.16s system 8% cpu 4.605 total

❯ time sift --no-group --no-color --err-skip-line-length function
sift --no-group --no-color --err-skip-line-length function  1.01s user 0.28s system 47% cpu 2.697 total

❯ time ag --nogroup --nocolor function 
ag --nogroup --nocolor function  0.57s user 0.21s system 12% cpu 6.283 total

❯ time pt --nogroup --nocolor function
pt --nogroup --nocolor function  0.23s user 0.17s system 13% cpu 2.853 total

感じたこと

  • siftは何かクセがあるのと、--err-skip-line-lengthというオプションを入れないと止まってしまった
  • hwは速い。微妙にag,ptとオプションが違うのが気になる
  • pt速くなっているっぽい

まとめ

うーむ、どれでも速いし、このままagでもいいかなぁ・・・