Class: BigBench::PostProcessor::Environment::Cluster

Inherits:
Object
  • Object
show all
Includes:
BigBench::PostProcessor::Environment
Defined in:
lib/bigbench/post_processor/environment.rb

Overview

Clusters the trackings in the specified timebase. By default everything is clustered by seconds.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BigBench::PostProcessor::Environment

#appearing, #cluster, #each_benchmark, #each_tracking, #normal_distribution, #polynomial_regression, reset!, #scope, #scope_to_benchmark, #statistics, #trackings

Constructor Details

#initialize(timebase = 1.second, scope = :all) ⇒ Cluster

Returns a new instance of Cluster.



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# 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

Instance Attribute Details

#durationsObject (readonly)

Returns the value of attribute durations.



335
336
337
# File 'lib/bigbench/post_processor/environment.rb', line 335

def durations
  @durations
end

#requestsObject (readonly)

Returns the value of attribute requests.



336
337
338
# File 'lib/bigbench/post_processor/environment.rb', line 336

def requests
  @requests
end

#timestepsObject (readonly)

Returns the value of attribute timesteps.



334
335
336
# File 'lib/bigbench/post_processor/environment.rb', line 334

def timesteps
  @timesteps
end

Class Method Details

.attr_multi_dimension_reader(attribute) ⇒ Object

Allows the registering of multi dimensioned attributes and 0s out values that aren’t present

attr_multi_dimension_reader :methods


327
328
329
330
331
332
# 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