Skip to content

Instantly share code, notes, and snippets.

@apotonick
Last active December 11, 2015 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apotonick/4545761 to your computer and use it in GitHub Desktop.
Save apotonick/4545761 to your computer and use it in GitHub Desktop.
xml = "<bla>" +
10000.times.collect { "<item />" }.join("") +
"</bla>"
puts( "elapsed time (xpath): " + Benchmark.realtime do
Nokogiri::XML(xml).root.search("./item")
end.to_s)
puts( "elapsed time: " + Benchmark.realtime do
Nokogiri::XML(xml).root.children.find_all do |cld|
cld.name == "item"
end
end.to_s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment