Why Compiled RegEx performance is slower than Intrepreted RegEx?

前端 未结 4 547
萌比男神i
萌比男神i 2020-12-05 07:47

I run into this article:

Performance: Compiled vs. Interpreted Regular Expressions, I modified the sample code to compile 1000 Regex and then run each 500 times to t

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 07:57

    http://www.codinghorror.com/blog/2005/03/to-compile-or-not-to-compile.html

    Compiled helps only if you instantiate it once and re-use it multiple times. If you're creating a compiled regex in the for loop then it obviously will perform worse. Can you show us your sample code?

提交回复
热议问题