Sha256: bd3bf65ad68d3c718fe43236bf25c8e955fde3792a0b743b76b6c2868e2dbd80

Contents?: true

Size: 1.22 KB

Versions: 29

Compression:

Stored size: 1.22 KB

Contents

require 'rubygems'
require File.dirname(__FILE__) + '/../../lib/feedzirra.rb'

require 'benchmark'
include Benchmark

urls = File.readlines(File.dirname(__FILE__) + "/../sample_feeds/successful_feed_urls.txt")
puts "benchmarks on #{urls.size} feeds"
puts "************************************"
benchmark do |t|
  feeds = {}
  t.report("feedzirra fetch and parse") do
    feeds = Feedzirra::Feed.fetch_and_parse(urls, 
      :on_success => lambda { |url, feed| $stdout.print '.'; $stdout.flush },
      :on_failure => lambda {|url, response_code, header, body| puts "#{response_code} ERROR on #{url}"})
  end
  
  # curb caches the dns lookups for 60 seconds. to make things fair we have to wait for the cache to expire
  puts "sleeping to wait for dns cache to clear"
  65.times {$stdout.print('.'); sleep(1)}
  puts "done"
  
  updated_feeds = []
  t.report("feedzirra update") do
    updated_feeds = Feedzirra::Feed.update(feeds.values.reject {|f| f.class == Fixnum}, 
      :on_success => lambda {|feed| $stdout.print '.'; $stdout.flush},
      :on_failure => lambda {|feed, response_code, header, body| puts "#{response_code} ERROR on #{feed.feed_url}"})
  end
  
  updated_feeds.each do |feed|
    puts feed.feed_url if feed.updated?
  end
end

Version data entries

29 entries across 29 versions & 10 rubygems

Version Path
Spectives-feedzirra-0.0.28 spec/benchmarks/updating_benchmarks.rb
Spectives-feedzirra-0.0.29 spec/benchmarks/updating_benchmarks.rb
Spectives-feedzirra-0.0.31 spec/benchmarks/updating_benchmarks.rb
Spectives-logophobia-feedzirra-0.0.31 spec/benchmarks/updating_benchmarks.rb
logophobia-feedzirra-0.0.20 spec/benchmarks/updating_benchmarks.rb
logophobia-feedzirra-0.0.21 spec/benchmarks/updating_benchmarks.rb
logophobia-feedzirra-0.0.22 spec/benchmarks/updating_benchmarks.rb
logophobia-feedzirra-0.0.27 spec/benchmarks/updating_benchmarks.rb
logophobia-feedzirra-0.0.28 spec/benchmarks/updating_benchmarks.rb
logophobia-feedzirra-0.0.31 spec/benchmarks/updating_benchmarks.rb
logophobia-logophobia-feedzirra-0.0.31 spec/benchmarks/updating_benchmarks.rb
rubylibre-feedzirra-0.0.23 spec/benchmarks/updating_benchmarks.rb
rubylibre-feedzirra-0.0.24 spec/benchmarks/updating_benchmarks.rb
rubylibre-feedzirra-0.0.25 spec/benchmarks/updating_benchmarks.rb
rubylibre-feedzirra-0.0.26 spec/benchmarks/updating_benchmarks.rb
feedzirra-0.2.1 spec/benchmarks/updating_benchmarks.rb
codders-feedzirra-0.2.0.rc2 spec/benchmarks/updating_benchmarks.rb
feedzirra-0.2.0.rc2 spec/benchmarks/updating_benchmarks.rb
feedzirra-0.2.0.rc1 spec/benchmarks/updating_benchmarks.rb
jashmenn-feedzirra-0.1.3 spec/benchmarks/updating_benchmarks.rb