LoginSignup
3
1

More than 5 years have passed since last update.

Rust combineのparse vs easy_parse

Posted at

はじめに

Rustのパーサコンビネータライブラリcombineにはパースを実行する関数としてparseeasy_parseの2種類の関数があります。後者は人が読みやすいパースエラーを生成できるのですが、実行速度に結構差があることに気づいたので比較してみました。
もちろんパーサの書き方依存の部分も大きいと思うので、結果は参考程度です。

条件

  • Rust: 1.33.0 stable
  • combine: 3.8.1
  • CPU: Xeon Gold 6134 @ 3.20GHz
  • OS: CentOS Linux release 7.6.1810 (Core)

比較したパーサは以下です。

結果

結果は以下のようになりました。横軸がファイルサイズで縦軸がスループットです。

parse_vs_easy_parse.png

ちょうどいいサイズのサンプルがなかったので間が空いてしまっています。100MB以下だけ拡大したものが以下です。

parse_vs_easy_parse_100MB.png

これをparse / easy_parseの比率に変換したものが以下です。

parse_vs_easy_parse_ratio.png

1個だけeasy_parseが異常に遅いケースがありますが、だいたい2倍程度違うようです。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1