require 'benchmark'
require 'open-uri'
require 'rss'
require 'rss/nokogiri'
uri = 'http://ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:%E6%9C%80%E8%BF%91%E3%81%AE%E6%9B%B4%E6%96%B0&feed=atom'
xml = open(uri) {|f| f.read}
Benchmark.bmbm do |x|
x.report 'REXML from URI' do
uri = URI('http://ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:%E6%9C%80%E8%BF%91%E3%81%AE%E6%9B%B4%E6%96%B0&feed=atom')
RSS::Parser.parse open(uri), true, true, RSS::REXMLParser
end
x.report 'Nokogiri from URI' do
uri = URI('http://ja.wikipedia.org/w/index.php?title=%E7%89%B9%E5%88%A5:%E6%9C%80%E8%BF%91%E3%81%AE%E6%9B%B4%E6%96%B0&feed=atom')
RSS::Parser.parse open(uri), true, true, RSS::NokogiriParser
end
x.report 'REXML from memory' do
RSS::Parser.parse xml, true, true, RSS::REXMLParser
end
x.report 'Nokogiri from memory' do
RSS::Parser.parse xml, true, true, RSS::NokogiriParser
end
end