Module: ABProf
- Defined in:
- lib/abprof.rb,
lib/abprof/benchmark_dsl.rb
Overview
Protocol:
Controller sends "ITERS [integer]\n"
Controller sends "QUIT\n" when done
Test process responds with "NOT OK\n" or crashes for bad results
Test process responds with "VALUE 27.23432" to explicitly return a single value
Test process responds with "VALUES [1.4, 2.714, 39.4, -71.4]" to explicitly return many values
QUIT requires no response.
Defined Under Namespace
Classes: ABBareProcess, ABHarnessProcess, ABWorker, BenchmarkInstance
Constant Summary collapse
- PROPERTIES =
These are primarily for DSL use.
[ :debug, :pvalue, :iters_per_trial, :min_trials, :max_trials, :burnin, :bare, :fail_on_divergence, :static_order ]
- SUMMARY_TYPES =
{ "mean" => proc { |samples| samples.inject(0.0, &:+) / samples.size }, "median" => proc { |samples| sz = samples.size sorted = samples.sort if sz % 2 == 1 # For odd-length, take middle element sorted[ samples.size / 2 ] else # For even length, mean of two middle elements (sorted[ sz / 2 ] + sorted[ sz / 2 + 1 ]) / 2.0 end }, }
- SUMMARY_METHODS =
SUMMARY_TYPES.keys
Class Method Summary collapse
Class Method Details
.compare(opts = {}, &block) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/abprof/benchmark_dsl.rb', line 158 def self.compare(opts = {}, &block) c = ABProf::BenchmarkInstance.new c.instance_eval &block raise "A DSL file must declare exactly two reports!" unless c.reports.size == 2 unless opts[:no_at_exit] at_exit do puts "Exit handler" if opts[:print_output] c.run_sampling opts end end c end |
.summarize(method, samples) ⇒ Object
118 119 120 121 122 |
# File 'lib/abprof.rb', line 118 def self.summarize(method, samples) raise "Unknown summary method #{method.inspect}!" unless SUMMARY_METHODS.include?(method.to_s) method_proc = SUMMARY_TYPES[method.to_s] method_proc.call(samples) end |