Skip to content

Commit ff07142

Browse files
committed
Add XPath a//a Benchmark
## Benchmark (Comparison with rexml 3.4.1) ``` $ benchmark-driver benchmark/xpath.yaml Calculating ------------------------------------- rexml 3.4.1 master 3.4.1(YJIT) master(YJIT) REXML::XPath.match(REXML::Document.new(xml), 'a//a') 29.130 227.729 108.669 497.976 i/s - 100.000 times in 3.432933s 0.439119s 0.920222s 0.200813s REXML::XPath.match([REXML::Document.new(xml), REXML::Document.new(xml)], 'a//a') 13.327 225.863 43.887 496.019 i/s - 100.000 times in 7.503386s 0.442747s 2.278585s 0.201605s Comparison: REXML::XPath.match(REXML::Document.new(xml), 'a//a') master(YJIT): 498.0 i/s master: 227.7 i/s - 2.19x slower 3.4.1(YJIT): 108.7 i/s - 4.58x slower rexml 3.4.1: 29.1 i/s - 17.10x slower REXML::XPath.match([REXML::Document.new(xml), REXML::Document.new(xml)], 'a//a') master(YJIT): 496.0 i/s master: 225.9 i/s - 2.20x slower 3.4.1(YJIT): 43.9 i/s - 11.30x slower rexml 3.4.1: 13.3 i/s - 37.22x slower ``` - YJIT=ON : 4.58x - 11.30x faster - YJIT=OFF : 7.81x - 16.95 faster
1 parent 4f0db41 commit ff07142

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

benchmark/xpath.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
loop_count: 100
2+
contexts:
3+
- gems:
4+
rexml: 3.2.6
5+
require: false
6+
prelude: require 'rexml'
7+
- name: master
8+
prelude: |
9+
$LOAD_PATH.unshift(File.expand_path("lib"))
10+
require 'rexml'
11+
- name: 3.2.6(YJIT)
12+
gems:
13+
rexml: 3.2.6
14+
require: false
15+
prelude: |
16+
require 'rexml'
17+
RubyVM::YJIT.enable
18+
- name: master(YJIT)
19+
prelude: |
20+
$LOAD_PATH.unshift(File.expand_path("lib"))
21+
require 'rexml'
22+
RubyVM::YJIT.enable
23+
24+
prelude: |
25+
require 'rexml/document'
26+
27+
DEPTH = 100
28+
xml = '<a>' * DEPTH + '</a>' * DEPTH
29+
doc1 = REXML::Document.new(xml)
30+
doc2 = REXML::Document.new(xml)
31+
32+
benchmark:
33+
"REXML::XPath.match(REXML::Document.new(xml), 'a//a')" : REXML::XPath.match(doc1, "a//a")
34+
"REXML::XPath.match([REXML::Document.new(xml), REXML::Document.new(xml)], 'a//a')" : REXML::XPath.match([doc1, doc2], "a//a")

0 commit comments

Comments
 (0)