Class: ABProf::ABBareProcess
- Inherits:
-
Object
- Object
- ABProf::ABBareProcess
- Defined in:
- lib/abprof.rb
Instance Attribute Summary collapse
-
#last_iters ⇒ Object
readonly
Returns the value of attribute last_iters.
-
#last_run ⇒ Object
readonly
Returns the value of attribute last_run.
Instance Method Summary collapse
- #debug(string) ⇒ Object
-
#initialize(command_line, opts = {}) ⇒ ABBareProcess
constructor
A new instance of ABBareProcess.
- #kill ⇒ Object
- #quit ⇒ Object
- #run_iters(n) ⇒ Object
Constructor Details
#initialize(command_line, opts = {}) ⇒ ABBareProcess
Returns a new instance of ABBareProcess.
132 133 134 135 |
# File 'lib/abprof.rb', line 132 def initialize command_line, opts = {} @command = command_line @debug = opts[:debug] end |
Instance Attribute Details
#last_iters ⇒ Object (readonly)
Returns the value of attribute last_iters.
126 127 128 |
# File 'lib/abprof.rb', line 126 def last_iters @last_iters end |
#last_run ⇒ Object (readonly)
Returns the value of attribute last_run.
125 126 127 |
# File 'lib/abprof.rb', line 125 def last_run @last_run end |
Instance Method Details
#debug(string) ⇒ Object
128 129 130 |
# File 'lib/abprof.rb', line 128 def debug string STDERR.puts(string) if @debug end |
#kill ⇒ Object
141 142 143 |
# File 'lib/abprof.rb', line 141 def kill # No-op end |
#quit ⇒ Object
137 138 139 |
# File 'lib/abprof.rb', line 137 def quit # No-op end |
#run_iters(n) ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/abprof.rb', line 145 def run_iters(n) t_start = t_end = nil debug "Controller of #{@pid}: #{n} ITERS" state = :succeeded n.times do if @command.respond_to?(:call) t_start = Time.now @command.call t_end = Time.now elsif @command.respond_to?(:to_s) t_start = Time.now system(@command.to_s) t_end = Time.now unless $?.success? STDERR.puts "Failing process #{@pid} after failed iteration(s), error code #{state.inspect}" # How to handle error with no self.kill? raise "Failure from command #{@command.inspect}, dying!" end else raise "Don't know how to execute bare object: #{@command.inspect}!" end end @last_run = [(t_end - t_start).to_f] @last_iters = n @last_run end |