performance_tester 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module PerformanceTester
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -111,8 +111,8 @@ module PerformanceTester
111
111
  def log
112
112
  puts "Success: #{outcome.success?}"
113
113
  puts "Number of requests: #{number_of_requests}"
114
- puts "Sum of request times: #{sum_of_times_of_all_requests}"
115
- puts "Total time elapsed: #{total_time_elapsed}"
114
+ puts "Sum of request times: #{sprintf("%.02f", sum_of_times_of_all_requests)}"
115
+ puts "Total time elapsed: #{sprintf("%.02f", total_time_elapsed)}"
116
116
  end
117
117
 
118
118
  def total_time_elapsed
@@ -152,7 +152,7 @@ module PerformanceTester
152
152
  def initialize(request, hosts)
153
153
  @url = URI.parse(request.url)
154
154
  @request_time = request.time
155
- @response = Response.new(request.response_parts)
155
+ @response = parse_response(request.response_parts)
156
156
  @host_aliases = hosts.invert
157
157
  end
158
158
 
@@ -187,15 +187,20 @@ module PerformanceTester
187
187
  def content_type
188
188
  response.content_type
189
189
  end
190
- end
191
190
 
192
- class Response < SimpleDelegator
193
- def initialize(response_parts)
194
- if !response_parts || response_parts.empty?
195
- raise ArgumentError, "Response parts are invalid"
191
+ def parse_response(response_parts)
192
+ if response_parts && !response_parts.empty?
193
+ response_parts.last
194
+ else
195
+ null_response
196
196
  end
197
- super(response_parts.last)
198
197
  end
198
+
199
+ def null_response
200
+ NullResponse.new(request_time, 0, '')
201
+ end
202
+
203
+ class NullResponse < Struct.new(:time, :status, :content_type); end
199
204
  end
200
205
  end
201
206
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: performance_tester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: