Created
May 12, 2009 17:03
-
-
Save Sixeight/110600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'rubygems' | |
require 'typhoeus' | |
require 'yaml' | |
class Github | |
include Typhoeus | |
remote_defaults :base_uri => 'http://github.com/api/v1/yaml', | |
:on_success => lambda {|responce| YAML.load(responce.body) }, | |
:on_failure => lambda {|responce| warn "error: #{responce.code}"; } | |
define_remote_method :search, :path => '/search/:word' | |
end | |
start = Time.now | |
res = [] | |
%w[ | |
ramaze rails sinatra typhoeus | |
ruby test Sixeight ujihisa | |
vim cucumber rspec factory_girl | |
pho perl erlan io potion why | |
].each do |proj| | |
res << Github.search(:word => proj) | |
end | |
res.map {|e| e['repositories'].count } | |
puts Time.now - start | |
require 'net/http' | |
Net::HTTP.version_1_2 | |
start = Time.now | |
Net::HTTP.start('github.com', 80) do |http| | |
%w[ | |
ramaze rails sinatra typhoeus | |
ruby test Sixeight ujihisa | |
vim cucumber rspec factory_girl | |
pho perl erlan io potion why | |
].map {|proj| | |
YAML.load http.get("/api/v1/yaml/search/#{proj}").body | |
}.map do |res| | |
res['repositories'].count | |
end | |
end | |
puts Time.now - start | |
#=> 1.64807 | |
#=> 12.186972 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment