Skip to content

Instantly share code, notes, and snippets.

@nahi
Created December 6, 2010 14:55
Show Gist options
  • Save nahi/730399 to your computer and use it in GitHub Desktop.
Save nahi/730399 to your computer and use it in GitHub Desktop.
Twitter gem, rubytter + httpclient, and Twitter4J with JRuby
0% jruby -rubygems trouble/twitter/twitter4j.rb
Rehearsal -----------------------------------------------
twitter gem 5.856000 0.000000 5.856000 ( 5.856000)
rubytter 5.844000 0.000000 5.844000 ( 5.845000)
twitter4j 1.730000 0.000000 1.730000 ( 1.730000)
------------------------------------- total: 13.430000sec
user system total real
twitter gem 4.850000 0.000000 4.850000 ( 4.850000)
rubytter 5.110000 0.000000 5.110000 ( 5.111000)
twitter4j 1.711000 0.000000 1.711000 ( 1.711000)
require 'benchmark'
require 'twitter'
Twitter.endpoint = 'http://api.twitter.com/1/' # hack for performance...
require 'rubytter'
require 'java'
require 'twitter4j-core-2.1.8-SNAPSHOT.jar'
include_class 'twitter4j.TwitterFactory'
include_class 'twitter4j.http.AccessToken'
ck = "XXX"
cs = "XXX"
ak = "XXX"
as = "XXX"
Benchmark.bmbm do |bm|
twitter_gem = Twitter::Client.new(:consumer_key => ck, :consumer_secret => cs, :oauth_token => ak, :oauth_token_secret => as)
rubytter = OAuthRubytter.new(:token => ak, :secret => as, :consumer => {:key => ck, :secret => cs})
twitter4j = TwitterFactory.new.get_oauth_authorized_instance(ck, cs, AccessToken.new(ak, as))
bm.report('twitter gem') do
5.times do
twitter_gem.home_timeline
end
end
bm.report('rubytter') do
5.times do
rubytter.home_timeline
end
end
bm.report('twitter4j') do
5.times do
twitter4j.home_timeline
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment