Class: WBench::Benchmark

Inherits:
Object
  • Object
show all
Defined in:
lib/wbench/benchmark.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Benchmark

Returns a new instance of Benchmark.



7
8
9
10
# File 'lib/wbench/benchmark.rb', line 7

def initialize(url, options = {})
  @url = url
  @browser = Browser.new(url, options)
end

Class Method Details

.run(url, options = {}) ⇒ Object



3
4
5
# File 'lib/wbench/benchmark.rb', line 3

def self.run(url, options = {})
  new(url, options).run(options[:loops] || DEFAULT_LOOPS)
end

Instance Method Details

#before_each(&blk) ⇒ Object



12
13
14
# File 'lib/wbench/benchmark.rb', line 12

def before_each(&blk)
  @before_each = blk
end

#run(loops) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/wbench/benchmark.rb', line 16

def run(loops)
  Results.new(@url, loops).tap do |results|
    loops.times do
      @browser.run(&@before_each)
      @browser.visit { results.add(app_server_results, browser_results, latency_results) }
    end
  end
end