Class: Bullshit::Histogram

Inherits:
Object
  • Object
show all
Defined in:
lib/bullshit.rb

Overview

A histogram gives an overview of measurement time values.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(analysis, bins) ⇒ Histogram

Create a Histogram for clock using the measurements for time.



574
575
576
577
578
# File 'lib/bullshit.rb', line 574

def initialize(analysis, bins)
  @analysis = analysis
  @bins = bins
  @result = compute
end

Instance Attribute Details

#binsObject (readonly)

Number of bins for this Histogram.



581
582
583
# File 'lib/bullshit.rb', line 581

def bins
  @bins
end

Instance Method Details

#display(output = $stdout, width = 50) ⇒ Object

Display this histogram to output, width is the parameter for prepare_display



590
591
592
593
594
595
596
# File 'lib/bullshit.rb', line 590

def display(output = $stdout, width = 50)
  d = prepare_display(width)
  for l, bar, r in d
    output << "%11.5f -|%s\n" % [ (l + r) / 2.0, "*" * bar ]
  end
  self
end

#to_aObject

Return the computed histogram as an array of arrays.



584
585
586
# File 'lib/bullshit.rb', line 584

def to_a
  @result
end