Class: PageResponseScale

Inherits:
Scale show all
Defined in:
lib/mobiusloop/scales/page_response_scale.rb

Overview

Records the response time of a web page

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Scale

#initialize

Constructor Details

This class inherits a constructor from Scale

Instance Attribute Details

#locationObject

Returns the value of attribute location.



10
11
12
# File 'lib/mobiusloop/scales/page_response_scale.rb', line 10

def location
  @location
end

Instance Method Details

#measureObject

returns a new Measure with response time of the :location



13
14
15
16
17
18
19
# File 'lib/mobiusloop/scales/page_response_scale.rb', line 13

def measure
  @location = "http://google.com" if @location == nil
  time = Benchmark.measure do
    response = Net::HTTP.get_response(URI.parse(@location))
  end
  Measure.new(time.real)
end