Module: BigBench::PostProcessor
- Defined in:
- lib/bigbench/post_processor.rb,
lib/bigbench/post_processor/graphs.rb,
lib/bigbench/post_processor/statistics.rb,
lib/bigbench/post_processor/environment.rb
Overview
Post processors are run after all test are finished and the results are written to the output file. A post processor can either be a block of code, or an existing post processor module. To setup a post processor simply do this:
post_process do
# Some code that is executed after the tests, like a database update, twitter post, email etc.
end
Or use one of the predefined post processor or write one yourself:
post_process :statistics
post_process BigBench::PostProcessor::Statistics
post_process "statistics"
All the upper lines include the same post processor. Symbols and strings are camelized and constantized as the module name.
Available Methods in Processors
Every post processor block or module supports the following methods and has full ActionView::Helper support.
- each_tracking
-
A method that iterates through every collected tracking. It automatically returns a hash with a single tracking of the following form:
{ :elapsed => 2.502132, :start => 1333986292.1755981, :stop => 1333986293.618884, :duration => 1443, :benchmark => "index page", :url => "http://www.google.de/", :path => "/", :method => "get", :status => 200 }
It can be used like this:
post_process do total_trackings, total_errors = 0, 0 each_tracking do |tracking| total_trackings += 1 total_errors += 1 unless tracking[:status] == 200 end Twitter.post "Just run BigBench with #{total_trackings} trackings and #{total_errors} errors." end
Defined Under Namespace
Modules: Context, Environment, Graphs, Statistics Classes: InvalidProcessor, Processor
Class Method Summary collapse
-
.add(processor = nil, options = nil, &block) ⇒ Object
Adds a new processor.
-
.all ⇒ Object
Returns all initialized processors.
-
.reset! ⇒ Object
Resets all post processors.
-
.run! ⇒ Object
Runs all post processors in the order they were defined.
Class Method Details
.add(processor = nil, options = nil, &block) ⇒ Object
Adds a new processor
108 109 110 |
# File 'lib/bigbench/post_processor.rb', line 108 def self.add(processor = nil, = nil, &block) @processors << Processor.new(processor, , &block) end |
.all ⇒ Object
Returns all initialized processors
113 114 115 |
# File 'lib/bigbench/post_processor.rb', line 113 def self.all @processors end |
.reset! ⇒ Object
Resets all post processors
118 119 120 121 |
# File 'lib/bigbench/post_processor.rb', line 118 def self.reset! @processors = [] Environment.reset! end |
.run! ⇒ Object
Runs all post processors in the order they were defined
57 58 59 |
# File 'lib/bigbench/post_processor.rb', line 57 def self.run! all.each{ |processor| processor.run! } end |