public
Description: A feed fetching and parsing library that treats the internet like Godzilla treats Japan: it dominates and eats all.
Homepage:
Clone URL: git://github.com/pauldix/feedzirra.git
commit  7fb5634c5c16e9c6ec971767b462c6518cd55f5d
tree    5e7403739b8ff14e982d8726f065e5aced5d4098
parent  6256d4832cff7e597f61157321e7fec9b1e2486b parent  1fa8c4585558f77e31a4492062e16975ed315ed9
feedzirra / spec / benchmarks / feedzirra_benchmarks.rb
100644 41 lines (36 sloc) 1.116 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require File.dirname(__FILE__) + '/../../lib/feedzirra.rb'
require 'rfeedparser'
require 'feed-normalizer'
require 'open-uri'
 
require 'benchmark'
include Benchmark
 
iterations = 10
urls = File.readlines(File.dirname(__FILE__) + "/../sample_feeds/successful_feed_urls.txt").slice(0, 20)
puts "benchmarks on #{urls.size} feeds"
puts "************************************"
benchmark do |t|
  t.report("feedzirra") do
    iterations.times do
      Feedzirra::Feed.fetch_and_parse(urls, :on_success => lambda { |url, feed| $stdout.print '.'; $stdout.flush })
    end
  end
 
  t.report("rfeedparser") do
    iterations.times do
      urls.each do |url|
        feed = FeedParser.parse(url)
        $stdout.print '.'
        $stdout.flush
      end
    end
  end
 
  t.report("feed-normalizer") do
    iterations.times do
      urls.each do |url|
        # have to use the :force option to make feed-normalizer parse an atom feed
        feed = FeedNormalizer::FeedNormalizer.parse(open(url), :force_parser => FeedNormalizer::SimpleRssParser)
        $stdout.print '.'
        $stdout.flush
      end
    end
  end
end