はてなダイアリーキーワード抽出・リンクを高速化したい2
id:higepon:20050912:1126515546の続き
まずは大雑把なベンチマークをということで
の2つを比較しました。
結果
Benchmark: timing 100 iterations of hatena, trie... hatena: 243 wallclock secs (239.68 usr + 0.03 sys = 239.71 CPU) @ 0.42/s (n=100) trie: 3 wallclock secs ( 0.00 usr 0.03 sys + 1.13 cusr 1.60 csys = 2.76 CPU) @ 3333.33/s (n=100)
約86倍!!。
体感速度だとキーワード抽出は一瞬。
比較スクリプト
sub hatena { makeincludewords($wordlist, $text); } sub trie { system("echo \"$text\" | ./hatenakeyword >/dev/null"); } sub main { Benchmark::timethese(100, { 'hatena' => \&hatena, 'trie' => \&trie, }); }
明日はSWIGのお勉強から。
*1:正確にはAC法ではないらし