module BigBench::Benchmark

Holds the actual benchmark methods. A benchmark is a sequence of requests to the same server, but to different paths. A testrun can consist of multiple benchmarks like this:

benchmark "default website pages" => "http://localhost:3000" do
   get "/"
   get "/blog"
   get "/imprint"
   get "/admin", :basic_auth => ['admin', 'secret']
end

benchmark "login and logout" => "http://localhost:3000" do
   post "/login", :params => { :name => "test@user.com", :password => "secret" }
   post "/logout", :params => { :name => "test@user.com" }
end

Those benchmarks automatically get added to the modules benchmark array and can be retrieved with the BigBench#benchmarks method.

Public Class Methods

add(options, &block) click to toggle source

Adds a benchmark to the BigBench module. It can later be retrieved with the all method.

# File lib/bigbench/benchmark.rb, line 63
def self.add(options, &block)
  name, url  = options.select{ |key, value| true unless key.is_a?(Symbol) }.first
  benchmark = Benchmark.new(name, url, options, &block)
  @benchmarks << benchmark
  benchmark
end
all() click to toggle source

Returns all benchmarks that are registered

# File lib/bigbench/benchmark.rb, line 71
def self.all
  @benchmarks
end
max_duration() click to toggle source

Returns the longest duration of all benchmarks

# File lib/bigbench/benchmark.rb, line 81
def self.max_duration
  all.map{ |benchmark| benchmark.duration }.max
end
reset!() click to toggle source

Resets all benchmarks

# File lib/bigbench/benchmark.rb, line 76
def self.reset!
  @benchmarks = []
end