Class: ApacheCrunch::ConfidenceInterval
- Inherits:
-
ProcedureRoutine
- Object
- ProcedureRoutine
- ApacheCrunch::ConfidenceInterval
- Defined in:
- lib/procedure_dsl.rb
Overview
DSL routine that determines a confidence interval for the values to which the block evaluates
For example,
confidence_interval 95 do
time_to_serve
end
would return two numbers, the lower and upper bound of a 95% confidence interval for the values of time_to_serve.
This routine returns a float, and the block must always evaluate to something with a to_f method.
Instance Method Summary collapse
Methods inherited from ProcedureRoutine
#finish, #initialize, #method_missing
Constructor Details
This class inherits a constructor from ApacheCrunch::ProcedureRoutine
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ApacheCrunch::ProcedureRoutine
Instance Method Details
#execute(confidence, &blk) ⇒ Object
216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/procedure_dsl.rb', line 216 def execute(confidence, &blk) # Build a list of all the values found values = [] while @_current_entry = @_log_parser.next_entry values << instance_eval(&blk).to_f end values.sort! # Determine how many values are outside the bounds of the CI count_outside = (values.length * (1.0 - confidence/100.0)).to_i # Find the bounds of the confidence interval return values[count_outside / 2], values[-count_outside / 2] end |