performance_tester 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/performance_tester/version.rb +1 -1
- data/lib/performance_tester.rb +14 -9
- metadata +1 -1
    
        data/lib/performance_tester.rb
    CHANGED
    
    | @@ -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 =  | 
| 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 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 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
         |