Class: B::Enchmark::Job
Overview
B::Enchmark::Job
Constant Summary collapse
- ATTRIBUTES =
[:group, :id, :rounds, :rate, :mean, :max, :min, :stddev, :x, :compare]
Instance Attribute Summary collapse
-
#x ⇒ Object
writeonly
Sets the attribute x.
Attributes inherited from Ase
Instance Method Summary collapse
-
#initialize(parent, id, opts, block) ⇒ Job
constructor
A new instance of Job.
- #run! ⇒ Object
- #to_h ⇒ Object
Methods inherited from Ase
Constructor Details
#initialize(parent, id, opts, block) ⇒ Job
Returns a new instance of Job.
101 102 103 104 105 |
# File 'lib/b.rb', line 101 def initialize(parent, id, opts, block) @opts = parent.opts.merge(opts) @parent, @block, @group, @id, @rounds, @compare = parent, block, parent.id, id, @opts[:rounds], @opts[:compare] @parent.register(self) end |
Instance Attribute Details
#x=(value) ⇒ Object (writeonly)
Sets the attribute x
98 99 100 |
# File 'lib/b.rb', line 98 def x=(value) @x = value end |
Instance Method Details
#run! ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/b.rb', line 107 def run! tm = Hitimes::TimedMetric.new(nil) @parent.start self @opts[:rounds].times do tm.start @block.call tm.stop end @rate, @mean, @max, @min, @stddev = tm.rate, tm.mean, tm.max, tm.min, tm.stddev finish self end |
#to_h ⇒ Object
119 120 121 122 123 124 |
# File 'lib/b.rb', line 119 def to_h ATTRIBUTES.reduce({}) { |m,e| m[e] = instance_variable_get('@'+e.to_s) m } end |