Skip to content

Instantly share code, notes, and snippets.

@alno
Created March 26, 2009 08:23
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 alno/85971 to your computer and use it in GitHub Desktop.
Save alno/85971 to your computer and use it in GitHub Desktop.
Benchmark for Ruby RSS parsers
# Becnhmark for Ruby RSS parsers
# Gems: syndication, rubyrss, simple-rss, feedtools
require 'benchmark'
require 'rubygems'
require 'open-uri'
require 'rss'
require 'simple-rss'
require 'feed_tools'
require 'syndication/rss'
require 'feed-normalizer'
def process_items( channel )
for i in channel.items do
i.link
i.title
i.description
end
end
def process_entries( channel )
for i in channel.entries do
i.url
i.title
i.description
end
end
def test_feed( x, fn )
feed_uri = 'http://localhost/' + fn + '.xml'
x.report(fn + ' std:') do
rss = RSS::Parser.parse open( feed_uri )
process_items( rss.channel )
end
x.report(fn + ' simple-rss:') do
rss = SimpleRSS.parse open( feed_uri )
process_items( rss )
end
x.report(fn + ' feed_tools:') do
rss = FeedTools::Feed.open( feed_uri )
process_items( rss )
end
x.report(fn + ' syndication:') do
rss = Syndication::RSS::Parser.new.parse open( feed_uri )
process_items( rss )
end
x.report(fn + ' feednormalizer:') do
rss = FeedNormalizer::FeedNormalizer.parse open( feed_uri )
process_entries( rss )
end
end
Benchmark.bm( 30 ) do |x|
test_feed( x, 'feed1' )
test_feed( x, 'feed2' )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment