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



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

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



185
186
187
# File 'lib/benelux.rb', line 185

def cstime
  @cstime
end

#cutimeObject

Returns the value of attribute cutime

Returns:

  • (Object)

    the current value of cutime



185
186
187
# File 'lib/benelux.rb', line 185

def cutime
  @cutime
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



185
186
187
# File 'lib/benelux.rb', line 185

def label
  @label
end

#realObject

Returns the value of attribute real

Returns:

  • (Object)

    the current value of real



185
186
187
# File 'lib/benelux.rb', line 185

def real
  @real
end

#samplesObject (readonly)



187
188
189
# File 'lib/benelux.rb', line 187

def samples
  @samples
end

#stimeObject

Returns the value of attribute stime

Returns:

  • (Object)

    the current value of stime



185
186
187
# File 'lib/benelux.rb', line 185

def stime
  @stime
end

#totalObject

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



185
186
187
# File 'lib/benelux.rb', line 185

def total
  @total
end

#utimeObject

Returns the value of attribute utime

Returns:

  • (Object)

    the current value of utime



185
186
187
# File 'lib/benelux.rb', line 185

def utime
  @utime
end

Instance Method Details

#inspectObject



214
215
216
217
218
219
220
221
# File 'lib/benelux.rb', line 214

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



197
198
199
200
201
202
203
204
# File 'lib/benelux.rb', line 197

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



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

def to_f
  total.mean.to_f
end

#to_iObject



208
209
210
# File 'lib/benelux.rb', line 208

def to_i
  total.mean.to_i
end

#to_sObject



211
212
213
# File 'lib/benelux.rb', line 211

def to_s
  total.mean.to_s
end