lib/b.rb in b-1.0.1 vs lib/b.rb in b-1.0.2

- old
+ new

@@ -9,11 +9,13 @@ DEFAULT_ROUNDS = 50 def self.enchmark(id='Untitled Benchmark', opts={}, &block) opts = {:output => ConsoleWriter.new}.merge(opts) opts[:parent] = opts[:output] - Blockenspiel.invoke(block, Enchmark.new(id, opts)).run! + em = Enchmark.new(id, opts) + Blockenspiel.invoke(block, em) + em.run! end # B::Ase class Ase include Blockenspiel::DSL @@ -22,11 +24,11 @@ dsl_methods false def run! @children.map {|c| c.run! unless c.nil?} unless @children.nil? post_run if self.respond_to? :post_run - @children.map(&:to_h) + @children.nil? ? [] : @children.map(&:to_h) end def register(job) @parent.register(job) if @parent.respond_to? :register end @@ -68,15 +70,11 @@ if @compare @buffer.sort! do |a,b| a.send(@compare) <=> b.send(@compare) end end - @buffer.each_with_index do |job, i| - if 0 == i - job.x = 1.0 - else - job.x = job.send(@compare) / @buffer[0].send(@compare) - end + @buffer.each do |job| + job.x = job.send(@compare) / @buffer[0].send(@compare) end until @buffer.empty? do @parent.start @buffer[0] @parent.finish @buffer.shift end