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"
end

benchmark "login and logout" => "http://localhost:3000" do
   post "/login", { :name => "test@user.com", :password => "secret" }
   post "/logout"
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 74
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 82
def self.all
  @benchmarks
end
max_duration() click to toggle source

Returns the longest duration of all benchmarks

# File lib/bigbench/benchmark.rb, line 92
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 87
def self.reset!
  @benchmarks = []
end