Clusters the trackings in the specified timebase. By default everything is clustered by seconds.
Allows the registering of multi dimensioned attributes and 0s out values that aren’t present
attr_multi_dimension_reader :methods
# File lib/bigbench/post_processor/environment.rb, line 327 def self.attr_multi_dimension_reader(attribute) define_method(attribute) do |appearance| variable = instance_variable_get("@#{attribute}".to_sym) variable.key?(appearance.to_s) ? variable[appearance.to_s] : timesteps.dup.fill(0) end end
# File lib/bigbench/post_processor/environment.rb, line 341 def initialize(timebase = 1.second, scope = :all) @timesteps, @durations, @durations_array, @requests, @methods, @statuses, @paths, @scope = [], [], [], [], {}, {}, {}, scope # Single dimension attributes steps = BigBench.config.duration.to_i / timebase (0..steps).to_a.each do |timestep| @timesteps[timestep] = timestep @durations_array[timestep] = [] @requests[timestep] = 0 end # Multi dimension attributes [:methods, :statuses, :paths].each do |attribute| appearing.send(attribute).each do |appearance| variable = instance_variable_get("@#{attribute}".to_sym) variable[appearance.to_s] = [] @timesteps.each { |timestep| variable[appearance.to_s][timestep] = 0 } end end # Cluster trackings trackings.each do |tracking| next if !(tracking[:benchmark] == scope or scope == :all) timestep = tracking[:elapsed].to_i / timebase @durations_array[timestep] << tracking[:duration] @requests[timestep] += 1 @methods[tracking[:method].to_s][timestep] += 1 @statuses[tracking[:status].to_s][timestep] += 1 @paths[tracking[:path].to_s][timestep] += 1 end # Compute mean of durations @timesteps.each do |timestep| @durations[timestep] = @durations_array[timestep].average end end