Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

find 謎の速度低下

$ pwd
/var/spool/news/articles/cclub
$ time sh -c 'find . | xargs grep "Yusuke Sato" > /dev/null'

real    0m0.866s
user    0m0.185s
sys     0m0.680s
$ time sh -c 'find /var/spool/news/articles/cclub | xargs grep "Yusuke Sato" > /dev/null'

real    0m1.150s
user    0m0.224s
sys     0m0.925s

find の引数が違うだけで、実行時間が 300ms 近く違う。

$ find . | xargs grep "Yusuke Sato" | wc -l
     266
$ find /var/spool/news/articles/cclub | xargs grep "Yusuke Sato" | wc -l     
     266

どっちも結果は同じなのになぁ。不思議。