Created
May 28, 2012 09:50
-
-
Save KitaitiMakoto/2818231 to your computer and use it in GitHub Desktop.
RSSライブラリーでREXMLを使う時とNokogiriを使う時のベンチマーク ref: http://qiita.com/items/ab872c13d2cf40fc572a
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
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 |
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment