Module: Benchmark::Experiment
- Included in:
- Benchmark
- Defined in:
- lib/benchmark/lab.rb,
lib/benchmark/lab/version.rb,
lib/benchmark/lab/mann_whitney_u_test.rb,
lib/benchmark/lab/descriptive_statistics.rb
Defined Under Namespace
Modules: MannWhitneyUTest
Classes: DescriptiveStatistics
Constant Summary
collapse
- MEASURED_TIMES =
{
utime: 'user',
stime: 'system',
total: 'total',
real: 'real'
}
- VERSION =
'0.0.1'
Instance Method Summary
collapse
Instance Method Details
#aggregate_and_rank(jsons) ⇒ Object
72
73
74
75
76
|
# File 'lib/benchmark/lab.rb', line 72
def aggregate_and_rank(jsons)
return if jsons.empty?
all_stats = jsons.inject({}) { |elem, hsh| hsh.merge(elem) }
rank(all_stats)
end
|
#experiment(sample_size, &blk) ⇒ Object
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/benchmark/lab.rb', line 78
def experiment(sample_size, &blk)
all_stats = JSON.parse(observe_and_summarize(sample_size, &blk))
print_stats(all_stats)
best, is_the_best_significative = rank(all_stats)
puts "The best \"#{best['label']}\" is #{is_the_best_significative ? '' : 'not '}significantly (95%) better (total time)."
all_stats
end
|
#iterative_experiment ⇒ Object
105
106
|
# File 'lib/benchmark/lab.rb', line 105
def iterative_experiment
end
|
#observe_and_summarize(sample_size) {|job| ... } ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/benchmark/lab.rb', line 64
def observe_and_summarize(sample_size, &blk)
job = Job.new(0)
yield(job)
job.observe_and_summarize(sample_size)
all_stats = job.list.map{ |label, _, _, stats| [label, stats] }.to_h
all_stats.to_json
end
|
#rank(all_stats, alpha = 0.05) ⇒ Object