class Benchmark

Public Class Methods

decimal_formatter() click to toggle source
# File lib/project/benchmark.rb, line 3
def decimal_formatter
  @_decimal_formatter ||= Potion::DecimalFormat.new("#,###,###")
end
run_single(setup_desc, code_desc, iterations, &block) click to toggle source
# File lib/project/benchmark.rb, line 11
def run_single(setup_desc, code_desc, iterations, &block)
  @total_run ||= 0
  start_time = Time.milliseconds_since_epoch
  iterations.times do
    @total_run += 1
    block.call
    #mp "[#{@total_run}]"
  end
  end_time = Time.milliseconds_since_epoch

  total_time = end_time - start_time
  per_item = total_time / iterations.to_f
  out =  "\nBenchmark  Started at: #{decimal_formatter.format(start_time)}"
  out << "\n  Iterations: #{decimal_formatter.format(iterations)}"
  out << "\n  Setup: #{setup_desc}\n  Code: #{code_desc}"
  out << "\n  Total milliseconds: #{decimal_formatter.format(total_time)}"
  out << "\n  Milliseconds per iteration: #{per_item}"
  out << "\n  RMQ allocations: #{$rmq_initialized.to_s}"
  mp out
  Potion::System.gc
  out
end
total_run() click to toggle source
# File lib/project/benchmark.rb, line 7
def total_run
  @total_run
end