Sha256: 2f45f6bb130e1b675c5b141a1851fd15dc8a592f9048da9af0e0fd0cc8154409
Contents?: true
Size: 834 Bytes
Versions: 1
Compression:
Stored size: 834 Bytes
Contents
module RBM class Fragment @@unnamed_fragment = "fragment_0" attr_reader :code, :name, :prerun, :postrun def initialize(code, name = nil, prerun = nil, postrun = nil) @code, @name, @prerun, @postrun = code, name, prerun, postrun end def run(bm, times, init = nil, cleanup = nil) fragment_name = (name || @@unnamed_fragment.succ!).gsub(/\s+/, "_") binding = Object.new.send(:binding) bm.report(name) do eval(init, binding, "#{fragment_name}_init", 0) if init eval(prerun, binding, "#{fragment_name}_prerun", 0) if prerun eval("#{times}.times { #{code} }", binding, "#{fragment_name}", 0) eval(postrun, binding, "#{fragment_name}_postrun", 0) if postrun eval(cleanup, binding, "#{fragment_name}_cleanup", 0) if cleanup end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rbm-1.0.1 | lib/rbm/fragment.rb |