Skip to content

Commit

Permalink
Changed performance testing to quicky gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
treeder committed Jul 4, 2012
1 parent 7df3d51 commit 0d1c1ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ GEM
ffi (1.0.11)
mime-types (1.18)
net-http-persistent (2.7)
quicky (0.0.1)
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)
Expand All @@ -24,6 +25,7 @@ PLATFORMS

DEPENDENCIES
net-http-persistent
quicky
rake
rest!
test-unit
Expand Down
1 change: 1 addition & 0 deletions rest.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "uber_config"
gem.add_development_dependency "typhoeus"
gem.add_development_dependency "net-http-persistent"
gem.add_development_dependency "quicky"

end

25 changes: 12 additions & 13 deletions test/test_performance.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
gem 'test-unit'
require 'test/unit'
require 'yaml'
require 'quicky'

require_relative 'test_base'

class TestTests < TestBase
Expand All @@ -11,30 +13,27 @@ def setup

def test_get_performance

times = 100
times = 10

collector = []
quicky = Quicky::Timer.new

collector << run_perf(times, :typhoeus)
collector << run_perf(times, :rest_client)
collector << run_perf(times, :net_http_persistent)
to_run = [:typhoeus, :rest_client, :net_http_persistent]
to_run.each do |gem|
run_perf(quicky, times, gem)
end

collector.each do |c|
p c
quicky.results.each_pair do |k, v|
puts "#{k}: #{v.duration}"
end

end

def run_perf(times, gem)
def run_perf(quicky, times, gem)
puts "Starting #{gem} test..."
t = Time.now
client = Rest::Client.new(:gem => gem)
times.times do |i|
quicky.loop(gem, times) do
client.get("http://requestb.in/ydyd4nyd")
end
duration = Time.now.to_f - t.to_f
puts "#{times} posts took #{duration}"
{:gem=>gem, :duration=>duration}
end

end
Expand Down

0 comments on commit 0d1c1ef

Please sign in to comment.