Skip to content
Browse files

Added quicky gem to time the operations.

(cherry-picked from 7666f28)
  • Loading branch information...
1 parent f13b945 commit 304a466fd17a8850620d344900211fa38a4b58f4 @treeder treeder committed Jan 31, 2013
Showing with 39 additions and 18 deletions.
  1. +2 −0 Gemfile.lock
  2. +1 −0 iron_mq.gemspec
  3. +36 −18 test/quick_run.rb
View
2 Gemfile.lock
@@ -18,6 +18,7 @@ GEM
mime-types (1.19)
minitest (4.4.0)
net-http-persistent (2.8)
+ quicky (0.4.0)
rake (10.0.3)
rest (2.2.0)
net-http-persistent
@@ -38,6 +39,7 @@ DEPENDENCIES
iron_mq!
minitest
net-http-persistent
+ quicky
rake
test-unit
typhoeus (>= 0.5.4)
View
1 iron_mq.gemspec
@@ -26,6 +26,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency "typhoeus", ">= 0.5.4"
gem.add_development_dependency "concur"
gem.add_development_dependency "net-http-persistent"
+ gem.add_development_dependency "quicky"
end
View
54 test/quick_run.rb
@@ -1,6 +1,7 @@
+require 'quicky'
require File.expand_path('test_base.rb', File.dirname(__FILE__))
-TIMES = 1
+TIMES = 10
class QuickRun < TestBase
@@ -10,27 +11,40 @@ def setup
clear_queue
end
- def test_basics
+ def test_quick
- TIMES.times do |i|
- puts "==== LOOP #{i} =================================="
+ quicky = Quicky::Timer.new
- res = @client.messages.post("hello world!")
- p res
- assert res.id
- post_id = res.id
- assert res.msg
+ # make connection
+ res2 = @client.messages.get()
+ p res2
- res = @client.messages.get()
- p res
- puts "post_id=" + post_id.inspect
- assert res.id
- assert_equal res.id, post_id
- assert res.body
+ quicky.loop(:test_quick, TIMES, :warmup => 2) do |i|
+ puts "==== LOOP #{i} =================================="
- res = @client.messages.delete(res["id"])
- p res
- assert res.msg
+ post_id = nil
+ quicky.time(:post, :warmup => 2) do
+ res = @client.messages.post("hello world!")
+ p res
+ assert res.id
+ post_id = res.id
+ assert res.msg
+ end
+
+ quicky.time(:get, :warmup => 2) do
+ res = @client.messages.get()
+ p res
+ puts "post_id=" + post_id.inspect
+ assert res.id
+ assert_equal res.id, post_id
+ assert res.body
+ end
+
+ quicky.time(:delete, :warmup => 2) do
+ res = @client.messages.delete(post_id)
+ p res
+ assert res.msg
+ end
res = @client.messages.get()
p res
@@ -49,6 +63,10 @@ def test_basics
res = res.delete
p res
end
+ puts "count: #{quicky.results(:post).count}"
+ puts "avg post: #{quicky.results(:post).duration}"
+ puts "avg get: #{quicky.results(:get).duration}"
+ puts "avg delete: #{quicky.results(:delete).duration}"
end

0 comments on commit 304a466

Please sign in to comment.
Something went wrong with that request. Please try again.