Class: Session
- Inherits:
-
Object
- Object
- Session
- Defined in:
- lib/session.rb
Overview
Simulation of a user that browses a site
Instance Method Summary collapse
- #add_request(*args) ⇒ Object
-
#initialize(options = {}) ⇒ Session
constructor
requests is an array of requests that will be run.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Session
requests is an array of requests that will be run
5 6 7 8 |
# File 'lib/session.rb', line 5 def initialize( = {}) @requests = [] @options = end |
Instance Method Details
#add_request(*args) ⇒ Object
10 11 12 13 14 |
# File 'lib/session.rb', line 10 def add_request(*args) args[1] ||= {} args[1].merge!(@options[:request_options] || {}) @requests << Request.new(*args) end |
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/session.rb', line 16 def run puts "Started session." run_times = [] @requests.each do |r| puts "Doing request to %s with a time on page of %0.02f..." % [r.url, r.time_on_page] run_times << { :request => r, :time => VisitBench.benchmark { r.do_request! } } sleep r.time_on_page end return run_times end |