class ApacheCrunch::Percentile
DSL routine that determines the nth percentile for the values to which the block evaluates
This routine returns a float, and the block must always evaluate to something with a to_f method.
Public Instance Methods
execute(n, &blk)
click to toggle source
# File lib/procedure_dsl.rb, line 238 def execute(n, &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! puts "values.length: #{values.length}" puts "n/100.0*values.length: #{n/100.0*values.length}" return values[((n/100.0)*values.length).to_i] end