Skip to content

perf(lex): use linear search over regex #514

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

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

JohelEGP
Copy link
Contributor

@JohelEGP JohelEGP commented Jun 16, 2023

Resolves #513.

For the following table:

  • Cppfront is built with the respective Cpp1 compiler configuration.
  • LLVM is shorthand for Clang and Libc++.

Legend:

  • main: The regex is an automatic object (branch main).
  • find_if: The keywords are stored in static vector and queried with std::find_if.
mixed-as-for-variant-20-types LLVM 17, Debug LLVM 17, Release GCC 13, Debug GCC 13, Release
Cppfront time (main) 11.28 s 0.94 s 3.44 s 0.45 s
Cppfront time (find_if) 0.08 s 0.01 s 0.08 s 0.01 s
#513 minimal reproducer LLVM 17, Debug LLVM 17, Release GCC 13, Debug GCC 13, Release
Cppfront time (main) 14.30 s 1.06 s 2.53 s 0.34 s
Cppfront time (find_if) 0.03 s 0.02 s 0.04 s 0.01 s
reflect.h LLVM 17, Debug LLVM 17, Release GCC 13, Debug GCC 13, Release
Cppfront time (main) 13.19 s 1.27 s 6.03 s 0.75 s
Cppfront time (find_if) 0.19 s 0.02 s 0.19 s 0.01 s

Testing summary:

100% tests passed, 0 tests failed out of 660

Total Test time (real) =  96.59 sec

Acknowledgements:

@JohelEGP JohelEGP changed the title perf: use std::vector and std::find_if over std::regex perf(lex): use linear search over regex Jun 16, 2023
@JohelEGP JohelEGP force-pushed the lex_perf_of_kw_rgx branch from e48e0c1 to 402de0f Compare June 16, 2023 18:09
@JohelEGP JohelEGP force-pushed the lex_perf_of_kw_rgx branch from 402de0f to a12fcbf Compare June 16, 2023 18:27
@hsutter hsutter merged commit 8345c2f into hsutter:main Jun 16, 2023
@JohelEGP JohelEGP deleted the lex_perf_of_kw_rgx branch June 16, 2023 18:49
zaucy pushed a commit to zaucy/cppfront that referenced this pull request Dec 5, 2023
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

Successfully merging this pull request may close these issues.

[BUG] perf: having many expressions is slow to lex
2 participants