Class: BenchmarkInterface::RBenchContext
- Inherits:
-
Object
- Object
- BenchmarkInterface::RBenchContext
- Defined in:
- lib/benchmark-interface/frontends/rbench.rb
Instance Method Summary collapse
- #column(name, options = nil) ⇒ Object
- #format(options) ⇒ Object
- #group(name) ⇒ Object
-
#initialize ⇒ RBenchContext
constructor
A new instance of RBenchContext.
- #rbench_benchmark(column_name, block) ⇒ Object
- #report(name, &block) ⇒ Object
- #summary(title) ⇒ Object
Constructor Details
#initialize ⇒ RBenchContext
Returns a new instance of RBenchContext.
13 14 15 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 13 def initialize @columns = [] end |
Instance Method Details
#column(name, options = nil) ⇒ Object
21 22 23 24 25 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 21 def column(name, =nil) singleton_class = (class << self; self end) singleton_class.class_eval "def #{name}(&block); rbench_benchmark #{name.inspect}, block; end" @columns.push name end |
#format(options) ⇒ Object
17 18 19 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 17 def format() # Ignore end |
#group(name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 27 def group(name) @group_name = name yield self ensure @group_name = nil end |
#rbench_benchmark(column_name, block) ⇒ Object
49 50 51 52 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 49 def rbench_benchmark(column_name, block) name = [@group_name, @report_name, column_name].compact.join('-') BenchmarkInterface.benchmark name, &block end |
#report(name, &block) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 34 def report(name, &block) if @columns.size == 0 BenchmarkInterface.benchmark name, &block else @report_name = name instance_eval &block end ensure @report_name = nil end |
#summary(title) ⇒ Object
45 46 47 |
# File 'lib/benchmark-interface/frontends/rbench.rb', line 45 def summary(title) # Ignore end |