Module: BigBench::Benchmark

Defined in:
lib/bigbench/benchmark.rb,
lib/bigbench/benchmark/looper.rb

Overview

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 => "[email protected]", :password => "secret" }
   post "/logout", :params => { :name => "[email protected]" }
end

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

Defined Under Namespace

Classes: Benchmark, Looper

Class Method Summary collapse

Class Method Details

.add(options, &block) ⇒ Object

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



63
64
65
66
67
68
# 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

.allObject

Returns all benchmarks that are registered



71
72
73
# File 'lib/bigbench/benchmark.rb', line 71

def self.all
  @benchmarks
end

.max_durationObject

Returns the longest duration of all benchmarks



81
82
83
# File 'lib/bigbench/benchmark.rb', line 81

def self.max_duration
  all.map{ |benchmark| benchmark.duration }.max
end

.reset!Object

Resets all benchmarks



76
77
78
# File 'lib/bigbench/benchmark.rb', line 76

def self.reset!
  @benchmarks = []
end