Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve
Node#each_recursive
performance (#139)
Fix #134 ## Summary This PR does: - Add `benchmark/each_recursive.yaml` - Rewrite `Node#each_recursive` implementation for performance - Add a test for `Node#each_recursive` The performance of `Node#each_recursive` is improved 60~80x faster. ## Details `each_recursive` is too much slow as I described in #134. I improved this performance by rewriting its implementation in this PR. Also, I added a benchmark in `benchmark/each_recursive.yaml` and the following is a result on my laptop: ``` RUBYLIB= BUNDLER_ORIG_RUBYLIB= /Users/makenowjust/Projects/github.com/makenowjust/simple-dotfiles/.asdf/installs/ruby/3.3.2/bin/ruby -v -S benchmark-driver /Users/makenowjust/Projects/github.com/ruby/rexml/benchmark/each_recursive.yaml ruby 3.3.2 (2024-05-30 revision e5a195edf6) [arm64-darwin23] Calculating ------------------------------------- rexml 3.2.6 master 3.2.6(YJIT) master(YJIT) each_recursive 11.279 686.502 17.926 1.470k i/s - 100.000 times in 8.866303s 0.145666s 5.578360s 0.068018s Comparison: each_recursive master(YJIT): 1470.2 i/s master: 686.5 i/s - 2.14x slower 3.2.6(YJIT): 17.9 i/s - 82.01x slower rexml 3.2.6: 11.3 i/s - 130.35x slower ``` We can see that the performance is improved 60~80x faster. Additionally, I added a new test for `Node#each_recursive`. It was missing, but we need it to confirm not to break the previous behavior. Thank you. --------- Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
- Loading branch information