Module: Bench

Defined in:
lib/bench.rb,
lib/bench/tms.rb,
lib/bench/runner.rb,
lib/bench/version.rb,
lib/bench/command.rb,
lib/bench/formatter.rb,
lib/bench/bench_file.rb,
lib/bench/command/run.rb,
lib/bench/command/plot.rb,
lib/bench/command/help.rb,
lib/bench/formatter/plot.rb,
lib/bench/command/report.rb

Overview

Benchmarking and complexity analyzer utility

Defined Under Namespace

Modules: Version Classes: BenchFile, Command, Formatter, Runner, Tms

Constant Summary

VERSION =
Version.to_s

Class Method Summary (collapse)

Class Method Details

+ (Object) bm(&block)

Builds a runner instance via the DSL definition given by the block.

Example

Bench.runner do |b|
  b.variation_point :ruby_version, Bench.which_ruby
  b.range_over([100, 1000, 10000, 100000], :runs) do |runs|
    b.variation_point :test, :via_reader do
      b.report{ runs.times{ foo.via_reader } }
    end
    b.variation_point :test, :via_method do
      b.report{ runs.times{ foo.via_method } }
    end
  end
end


40
41
42
# File 'lib/bench.rb', line 40

def self.bm(&block)
  Runner.new(block)
end

+ (Object) measure(&block)



20
21
22
# File 'lib/bench.rb', line 20

def self.measure(&block)
  Bench::Tms.coerce Benchmark.measure(&block)
end

+ (Object) Tms(*args)

Builds a Tms object



16
17
18
# File 'lib/bench.rb', line 16

def self.Tms(*args)
  Bench::Tms.coerce(args)
end

+ (Object) which_ruby

Returns a short string with a ruby interpreter description



47
48
49
50
51
52
53
54
# File 'lib/bench.rb', line 47

def self.which_ruby
  if Object.const_defined?(:RUBY_DESCRIPTION)
    RUBY_DESCRIPTION =~ /^([^\s]+\s*[^\s]+)/
    $1
  else
    "ruby #{RUBY_VERSION} (#{RUBY_PLATFORM})"
  end
end