1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RSSライブラリーでREXMLを使う時とNokogiriを使う時のベンチマーク

Posted at
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
Rehearsal --------------------------------------------------------
REXML from URI         0.550000   0.000000   0.550000 (  2.712987)
Nokogiri from URI      0.170000   0.000000   0.170000 (  3.078010)
REXML from memory      0.540000   0.000000   0.540000 (  0.544707)
Nokogiri from memory   0.120000   0.000000   0.120000 (  0.122050)
----------------------------------------------- total: 1.380000sec

                           user     system      total        real
REXML from URI         0.560000   0.020000   0.580000 (  2.653760)
Nokogiri from URI      0.180000   0.000000   0.180000 (  3.760438)
REXML from memory      0.530000   0.000000   0.530000 (  0.534338)
Nokogiri from memory   0.100000   0.000000   0.100000 (  0.102664)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?