Class: BenchmarkHarness::Collection
- Defined in:
- lib/benchmark_harness/collection.rb
Constant Summary collapse
- KEYS =
order corresponds to values in each sample
[:user, :system, :children_user, :children_system, :real]
- STATS =
[:mean, :median, :mode, :range, :min, :max, :sum, :standard_deviation, :variance]
- STATS_HUMAN =
STATS.collect{|s| s.to_s.sub(/_/, " ").capitalize}
Instance Method Summary collapse
-
#print ⇒ Object
Formatted output.
-
#reconciled ⇒ Object
Sorts values into named vectors:.
Methods included from Stats
included, #mean, #median, #mode, #range, #standard_deviation, #sum_of_deviations_squared, #variance
Instance Method Details
#print ⇒ Object
Formatted output
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/benchmark_harness/collection.rb', line 44 def print label_size = STATS_HUMAN.max{|a, b| a.size <=> b.size}.size puts sprintf("%#{label_size}s %d", "Samples:", self.size) if self.size > 0 puts sprintf("%#{label_size}s: %10s %10s %10s %10s %10s", "Displaying", "user", "system", "ch.user", "ch.system", "real") STATS_HUMAN.each_with_index do |label, i| puts sprintf("%#{label_size}s: %10.4g %10.4g %10.4g %10.4g %10.4g", label, *KEYS.collect{|k| self.send(STATS[i], k)}) end end end |
#reconciled ⇒ Object
Sorts values into named vectors:
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/benchmark_harness/collection.rb', line 12 def reconciled return @reconciled if @reconciled @reconciled = Hash.new{|h,k| h[k] = []} self.each do |sample| KEYS.each_with_index do |key, index| @reconciled[key] << sample[index] end end @reconciled end |