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
Class Method Summary collapse
-
.add(options, &block) ⇒ Object
Adds a benchmark to the
BigBench
module. -
.all ⇒ Object
Returns all benchmarks that are registered.
-
.max_duration ⇒ Object
Returns the longest duration of all benchmarks.
-
.reset! ⇒ Object
Resets all benchmarks.
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(, &block) name, url = .select{ |key, value| true unless key.is_a?(Symbol) }.first benchmark = Benchmark.new(name, url, , &block) @benchmarks << benchmark benchmark end |
.all ⇒ Object
Returns all benchmarks that are registered
71 72 73 |
# File 'lib/bigbench/benchmark.rb', line 71 def self.all @benchmarks end |
.max_duration ⇒ Object
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 |