Class: Benelux::Tms

Inherits:
Struct show all
Defined in:
lib/benelux.rb

Overview

Similar to Benchmark::Tms with the addition of standard deviation, mean, and total, for each of the data times.

tms = Benelux::Tms.new
tms.real.sd       # standard deviation
tms.utime.mean    # mean value
tms.total.n       # number of data points

See Benelux::Stats::Calculator

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tms = nil) ⇒ Tms

tms is a Benchmark::Tms object



183
184
185
186
187
188
189
190
# File 'lib/benelux.rb', line 183

def initialize tms=nil
  @samples = 0
  members.each_with_index { |n, index| 
    next if n.to_s == 'label'
    self.send("#{n}=", Stats::Calculator.new)
  }
  sample tms unless tms.nil?
end

Instance Attribute Details

#cstimeObject

Returns the value of attribute cstime

Returns:

  • (Object)

    the current value of cstime



179
180
181
# File 'lib/benelux.rb', line 179

def cstime
  @cstime
end

#cutimeObject

Returns the value of attribute cutime

Returns:

  • (Object)

    the current value of cutime



179
180
181
# File 'lib/benelux.rb', line 179

def cutime
  @cutime
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



179
180
181
# File 'lib/benelux.rb', line 179

def label
  @label
end

#realObject

Returns the value of attribute real

Returns:

  • (Object)

    the current value of real



179
180
181
# File 'lib/benelux.rb', line 179

def real
  @real
end

#samplesObject (readonly)



181
182
183
# File 'lib/benelux.rb', line 181

def samples
  @samples
end

#stimeObject

Returns the value of attribute stime

Returns:

  • (Object)

    the current value of stime



179
180
181
# File 'lib/benelux.rb', line 179

def stime
  @stime
end

#totalObject

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



179
180
181
# File 'lib/benelux.rb', line 179

def total
  @total
end

#utimeObject

Returns the value of attribute utime

Returns:

  • (Object)

    the current value of utime



179
180
181
# File 'lib/benelux.rb', line 179

def utime
  @utime
end

Instance Method Details

#inspectObject



208
209
210
211
212
213
214
215
# File 'lib/benelux.rb', line 208

def inspect
  fields = members.collect { |f| 
    next unless Stats::Calculator === self.send(f)
    '%s=%.2f@%.2f' % [f, self.send(f).mean, self.send(f).sd] 
  }.compact
  args = [self.class.to_s, self.hexoid, samples, fields.join(' ')]
  '#<%s:%s samples=%d %s>' % args
end

#sample(tms) ⇒ Object



191
192
193
194
195
196
197
198
# File 'lib/benelux.rb', line 191

def sample(tms)
  @samples += 1
  self.label ||= tms.label
  members.each_with_index { |n, index| 
    next if n.to_s == 'label'
    self.send(n).sample tms.send(n) || 0
  }
end

#to_fObject



199
200
201
# File 'lib/benelux.rb', line 199

def to_f
  total.mean.to_f
end

#to_iObject



202
203
204
# File 'lib/benelux.rb', line 202

def to_i
  total.mean.to_i
end

#to_sObject



205
206
207
# File 'lib/benelux.rb', line 205

def to_s
  total.mean.to_s
end