class BigBench::Benchmark::Benchmark

Attributes

duration[RW]
fragments[RW]
is_running[RW]
name[RW]
runs[RW]
start[RW]
tracker[RW]
uri[RW]
users[RW]

Public Class Methods

new(name, url, options, &block) click to toggle source

Initizalizes a new benchmark

# File lib/bigbench/benchmark.rb, line 36
def initialize(name, url, options, &block)
  @name, @uri, @tracker, @is_running, @runs = name, URI(url), Tracker::Tracker.new, false, 0
  @users      = options[:users]     || BigBench.config.users
  @duration   = options[:duration]  || BigBench.config.duration
  @fragments  = BigBench::Fragment.parse(self, &block)
end

Public Instance Methods

is_running?() click to toggle source

Returns if this benchmark is currently running

# File lib/bigbench/benchmark.rb, line 56
def is_running?
  @is_running
end
run!() click to toggle source

Execute this benchmark

# File lib/bigbench/benchmark.rb, line 44
def run!
  
  # Setup Timer
  timer = Thread.new{ sleep(@duration); @is_running = false }
  @start, @is_running = Time.now, true
  
  # Loop Requests
  @users.times { Looper.new(self).loop! }
  @runs += 1
end