-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize the parse_attributes method to use
Source#match
to parse XML.
## Why? Improve maintainability by consolidating processing into `Source#match`. ## [Benchmark] ``` RUBYLIB= BUNDLER_ORIG_RUBYLIB= /Users/naitoh/.rbenv/versions/3.3.0/bin/ruby -v -S benchmark-driver /Users/naitoh/ghq/github.com/naitoh/rexml/benchmark/parse.yaml ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin22] Calculating ------------------------------------- before after before(YJIT) after(YJIT) dom 10.193 10.886 16.969 18.136 i/s - 100.000 times in 9.810390s 9.186087s 5.893093s 5.513848s sax 30.812 30.131 50.759 55.520 i/s - 100.000 times in 3.245535s 3.318887s 1.970105s 1.801142s pull 36.413 35.511 60.692 68.538 i/s - 100.000 times in 2.746293s 2.816067s 1.647660s 1.459039s stream 34.968 34.461 52.797 60.311 i/s - 100.000 times in 2.859738s 2.901858s 1.894046s 1.658079s Comparison: dom after(YJIT): 18.1 i/s before(YJIT): 17.0 i/s - 1.07x slower after: 10.9 i/s - 1.67x slower before: 10.2 i/s - 1.78x slower sax after(YJIT): 55.5 i/s before(YJIT): 50.8 i/s - 1.09x slower before: 30.8 i/s - 1.80x slower after: 30.1 i/s - 1.84x slower pull after(YJIT): 68.5 i/s before(YJIT): 60.7 i/s - 1.13x slower before: 36.4 i/s - 1.88x slower after: 35.5 i/s - 1.93x slower stream after(YJIT): 60.3 i/s before(YJIT): 52.8 i/s - 1.14x slower before: 35.0 i/s - 1.72x slower after: 34.5 i/s - 1.75x slower ``` - YJIT=ON : 1.07x - 1.14x faster - YJIT=OFF : 0.97x - 1.06x faster
- Loading branch information
Showing
3 changed files
with
53 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters