Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern compilation should not be included in elapsed time #2

Closed
h12w opened this issue Sep 28, 2017 · 2 comments
Closed

Pattern compilation should not be included in elapsed time #2

h12w opened this issue Sep 28, 2017 · 2 comments

Comments

@h12w
Copy link

h12w commented Sep 28, 2017

A compiled regular expression is almost always used rather than recompiling each time.
And the measurement should be an average of multiple times.
A benchmark is only useful if it is close enough to real applications.

@mariomka
Copy link
Owner

Pattern compilation is a necessary part of regex process and not always patterns can be reused. I'm sorry but the benchmark can’t be good for all scenarios.

Anyway, I have tested it again and the results are similar:

Including pattern compilation:

C PCRE2 | 24.59 | 23.55 | 5.55 | 53.69
Rust | 29.02 | 27.97 | 6.28 | 63.28
PHP | 53.38 | 49.97 | 5.33 | 108.67
Javascript | 78.66 | 63.92 | 2.01 | 144.59
D ldc | 142.25 | 135.63 | 4.79 | 282.67
D dmd | 200.00 | 195.35 | 5.70 | 401.06
Perl | 239.81 | 168.08 | 44.65 | 452.54
Crystal | 332.21 | 272.89 | 26.84 | 631.94
Ruby | 338.32 | 290.29 | 51.11 | 679.72
Python PyPy | 204.90 | 171.47 | 323.83 | 700.20
Java | 375.97 | 460.51 | 288.50 | 1124.98
Kotlin | 389.48 | 460.31 | 289.03 | 1138.82
Python 2 | 366.29 | 286.07 | 498.07 | 1150.44
Python 3 | 568.25 | 416.31 | 489.55 | 1474.11
Go | 412.98 | 404.22 | 703.53 | 1520.73
C# .Net Core | 1908.27 | 1654.43 | 109.74 | 3672.44
C# Mono | 2355.97 | 2025.43 | 147.90 | 4529.30

Excluding pattern compilation (if apply):

C PCRE2 | 23.84 | 23.53 | 5.82 | 53.19
Rust | 27.30 | 28.67 | 6.14 | 62.11
PHP | 53.39 | 48.43 | 5.26 | 107.08
Javascript | 77.64 | 62.83 | 1.92 | 142.39
D ldc | 143.50 | 137.39 | 5.08 | 285.97
D dmd | 200.42 | 195.75 | 5.46 | 401.63
Perl | 239.37 | 165.62 | 44.55 | 449.54
Crystal | 335.80 | 274.04 | 26.54 | 636.38
Ruby | 335.38 | 294.44 | 52.37 | 682.19
Python PyPy | 203.62 | 170.96 | 326.98 | 701.57
Java | 375.25 | 453.16 | 290.51 | 1118.91
Python 2 | 361.41 | 275.90 | 492.16 | 1129.46
Kotlin | 385.70 | 465.36 | 287.34 | 1138.40
Python 3 | 548.91 | 403.32 | 481.29 | 1433.52
Go | 412.31 | 405.62 | 700.31 | 1518.25
C# .Net Core | 1907.12 | 1658.22 | 109.74 | 3675.08
C# Mono | 2447.18 | 2096.15 | 156.32 | 4699.65

By the way, you can check the run-benchmarks.php to see that measurement is the average of ten executions, maybe execute more times is more accurate but I think is enough.

@h12w
Copy link
Author

h12w commented Sep 29, 2017

I have tested myself and I agree with you. The result does not make significant difference whether including pattern compilation or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants