正则表达式性能:Boost vs. Perl [英] Regular expressions performance: Boost vs. Perl

查看:225
本文介绍了正则表达式性能:Boost vs. Perl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找perl和boost正则表达式之间的性能比较。

我需要设计一段代码,它非常依赖于正则表达式,并且可以选择:


  1. 通过boost regex运行它

  2. 调度perl解释器并在perl中执行工作

我知道perl以其优化的字符串处理而闻名。但是,我找不到性能比较来提升regex库。

你知道任何这样的比较吗?

感谢



真正的答案是,我不知道任何这样的比较,但是Perl的正则表达式设施不一定是最快的。有关某些表达式的Perl正则表达式的算法的某些信息,请参见此处。 / p>

编辑:可以通过链接到libperl或使用 libPCRE 。如果你需要它们,使用boost可能会给你更多的灵活性和性能调整选项。



final注意:boost.regex和Perl的regex之间没有直接的比较性能条款。解决方案是尝试两者,看看哪些是更好的OP的具体情况。



(编辑:现在Boost和PCRE之间有一个很好的比较。 href =http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/gcc-performance.html =nofollow> http://www.boost.org/doc/libs /1_41_0/libs/regex/doc/gcc-performance.html )


I'm looking for a performance comparison between perl and boost regular expression.
I need to design a piece of code which relies very heavily on regular expressions, and can choose between:

  1. running it through a boost regex
  2. dispatching a perl interpreter and do the work in perl

I know perl is known for it's optimized string processing. However, I can't find a performance comparison to boost regex library.
Do you know of any such comparison?
Thanks

解决方案

The startup cost of running a Perl interpreter from within your application (via the system function I presume) will outweigh any benefits you gain over using Perl's regex engine. The exception would be if you have a VERY complicated regular expression that Perl's regex implementation happens to be optimised for but boost's regex engine isn't.

The real answer is that I do not know of any such comparison, but Perl's regular expression facilities are not necessarily the fastest. See here for some information about an algorithm that beats Perl's regular expression for some expressions.

EDIT: It is possible to overcome the startup cost of starting a full perl interpreter by linking to libperl or using libPCRE. And using boost will probably give you more flexibility and performance tuning options if you need them.

Final Note: There are no known direct comparisons between boost.regex and Perl's regex in terms of performance. The solution is to try both and see which is more performant for the OP's specific situation.

(Edit : There is now a good comparison between Boost and PCRE. See http://www.boost.org/doc/libs/1_41_0/libs/regex/doc/gcc-performance.html)

这篇关于正则表达式性能:Boost vs. Perl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆