Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 33 lines (28 sloc) 1.248 kb
45d6431 Paul Dix added pure fetching benchmark using the feedzirra curb method and regula...
pauldix authored
1 require 'rubygems'
2 require File.dirname(__FILE__) + '/../../lib/feedzirra.rb'
3
4 require 'benchmark'
5 include Benchmark
6
7 urls = File.readlines(File.dirname(__FILE__) + "/../sample_feeds/successful_feed_urls.txt")
8 puts "benchmarks on #{urls.size} feeds"
9 puts "************************************"
10 benchmark do |t|
11 feeds = {}
12 t.report("feedzirra fetch and parse") do
13 feeds = Feedzirra::Feed.fetch_and_parse(urls,
14 :on_success => lambda { |url, feed| $stdout.print '.'; $stdout.flush },
15 :on_failure => lambda {|url, response_code, header, body| puts "#{response_code} ERROR on #{url}"})
16 end
17
18 # curb caches the dns lookups for 60 seconds. to make things fair we have to wait for the cache to expire
19 puts "sleeping to wait for dns cache to clear"
20 65.times {$stdout.print('.'); sleep(1)}
21 puts "done"
22
23 updated_feeds = []
24 t.report("feedzirra update") do
25 updated_feeds = Feedzirra::Feed.update(feeds.values.reject {|f| f.class == Fixnum},
26 :on_success => lambda {|feed| $stdout.print '.'; $stdout.flush},
27 :on_failure => lambda {|feed, response_code, header, body| puts "#{response_code} ERROR on #{feed.feed_url}"})
28 end
29
30 updated_feeds.each do |feed|
31 puts feed.feed_url if feed.updated?
32 end
33 end
Something went wrong with that request. Please try again.