Skip to content

Instantly share code, notes, and snippets.

@Sixeight
Created May 12, 2009 17:03
Show Gist options
  • Save Sixeight/110600 to your computer and use it in GitHub Desktop.
Save Sixeight/110600 to your computer and use it in GitHub Desktop.
# -*- 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