つーわけで
CFLAGS='-pg' ./configureしましたよ。
(実機サーバで)
grepは2.5.1aと2.3、jgrepは2.3ベースのやつ。
んで、153個のファイル(バイナリあり、日本語テキストばかり)を対象に検索。
fgrepとjgrep(普通のgrepだと、1単語でもDFA作っちゃう)をgprofで比較するとこちら。
fgrep 2.3
time seconds seconds calls Ts/call Ts/call name 0.00 0.00 0.00 317 0.00 0.00 fillbuf 0.00 0.00 0.00 204 0.00 0.00 Fexecute 0.00 0.00 0.00 204 0.00 0.00 bmexec 0.00 0.00 0.00 204 0.00 0.00 grepbuf 0.00 0.00 0.00 204 0.00 0.00 kwsexec 0.00 0.00 0.00 154 0.00 0.00 grep 0.00 0.00 0.00 154 0.00 0.00 grepfile 0.00 0.00 0.00 154 0.00 0.00 reset 0.00 0.00 0.00 3 0.00 0.00 page_alloc 0.00 0.00 0.00 1 0.00 0.00 Fcompile 0.00 0.00 0.00 1 0.00 0.00 kwsalloc 0.00 0.00 0.00 1 0.00 0.00 kwsincr 0.00 0.00 0.00 1 0.00 0.00 kwsinit 0.00 0.00 0.00 1 0.00 0.00 kwsprep 0.00 0.00 0.00 1 0.00 0.00 setmatcher 0.00 0.00 0.00 1 0.00 0.00 xmalloc
fgrep 2.5.1a
time seconds seconds calls us/call us/call name 75.00 0.03 0.03 221 135.75 135.75 check_multibyte_string 25.00 0.04 0.01 221 45.25 45.25 bmexec 0.00 0.04 0.00 335 0.00 0.00 fillbuf 0.00 0.04 0.00 221 0.00 181.01 Fexecute 0.00 0.04 0.00 221 0.00 181.01 grepbuf 0.00 0.04 0.00 221 0.00 45.25 kwsexec 0.00 0.04 0.00 153 0.00 261.45 grep 0.00 0.04 0.00 153 0.00 261.45 grepfile 0.00 0.04 0.00 153 0.00 0.00 reset 0.00 0.04 0.00 5 0.00 0.00 xmalloc 0.00 0.04 0.00 1 0.00 0.00 Fcompile 0.00 0.04 0.00 1 0.00 0.00 close_stdout_status 0.00 0.04 0.00 1 0.00 0.00 get_nondigit_option 0.00 0.04 0.00 1 0.00 0.00 install_matcher 0.00 0.04 0.00 1 0.00 0.00 kwsalloc 0.00 0.04 0.00 1 0.00 0.00 kwsincr 0.00 0.04 0.00 1 0.00 0.00 kwsinit 0.00 0.04 0.00 1 0.00 0.00 kwsprep 0.00 0.04 0.00 1 0.00 0.00 prepend_default_options 0.00 0.04 0.00 1 0.00 0.00 setmatcher
jgrep
time seconds seconds calls Ts/call Ts/call name 0.00 0.00 0.00 315 0.00 0.00 fillbuf 0.00 0.00 0.00 203 0.00 0.00 EGexecute 0.00 0.00 0.00 203 0.00 0.00 bmexec 0.00 0.00 0.00 203 0.00 0.00 grepbuf 0.00 0.00 0.00 203 0.00 0.00 kwsexec 0.00 0.00 0.00 153 0.00 0.00 grep 0.00 0.00 0.00 153 0.00 0.00 grepfile 0.00 0.00 0.00 153 0.00 0.00 reset 0.00 0.00 0.00 40 0.00 0.00 ifree 0.00 0.00 0.00 25 0.00 0.00 icatalloc 0.00 0.00 0.00 22 0.00 0.00 xmalloc 0.00 0.00 0.00 18 0.00 0.00 istrstr 0.00 0.00 0.00 15 0.00 0.00 copy 0.00 0.00 0.00 14 0.00 0.00 freelist 0.00 0.00 0.00 13 0.00 0.00 icpyalloc 0.00 0.00 0.00 10 0.00 0.00 enlist 0.00 0.00 0.00 9 0.00 0.00 addtok 0.00 0.00 0.00 6 0.00 0.00 epsclosure 0.00 0.00 0.00 5 0.00 0.00 lex 0.00 0.00 0.00 4 0.00 0.00 atom 0.00 0.00 0.00 4 0.00 0.00 closure 0.00 0.00 0.00 4 0.00 0.00 merge 0.00 0.00 0.00 4 0.00 0.00 resetmust 0.00 0.00 0.00 4 0.00 0.00 xrealloc 0.00 0.00 0.00 3 0.00 0.00 addlists 0.00 0.00 0.00 3 0.00 0.00 page_alloc 0.00 0.00 0.00 1 0.00 0.00 Gcompile 0.00 0.00 0.00 1 0.00 0.00 branch 0.00 0.00 0.00 1 0.00 0.00 dfaanalyze 0.00 0.00 0.00 1 0.00 0.00 dfacomp 0.00 0.00 0.00 1 0.00 0.00 dfainit 0.00 0.00 0.00 1 0.00 0.00 dfamust 0.00 0.00 0.00 1 0.00 0.00 dfaparse 0.00 0.00 0.00 1 0.00 0.00 dfasyntax 0.00 0.00 0.00 1 0.00 0.00 insert 0.00 0.00 0.00 1 0.00 0.00 kwsalloc 0.00 0.00 0.00 1 0.00 0.00 kwsincr 0.00 0.00 0.00 1 0.00 0.00 kwsinit 0.00 0.00 0.00 1 0.00 0.00 kwsmusts 0.00 0.00 0.00 1 0.00 0.00 kwsprep 0.00 0.00 0.00 1 0.00 0.00 regexp 0.00 0.00 0.00 1 0.00 0.00 setmatcher 0.00 0.00 0.00 1 0.00 0.00 state_index 0.00 0.00 0.00 1 0.00 0.00 xcalloc 0.00 0.00 0.00 1 0.00 0.00 xmalloc
というわけで、
grepがバージョンあがってマルチバイト対応が
しっかりして足を引っ張っている模様。
しかし、bmexecの速度もえらく違います。
bmexecの中身はそんなに変わっていないのに。。。