Method: CPU::Processor#usage
- Defined in:
- lib/cpu/processor.rb
#usage(interval = 1, &block) ⇒ Object
Measure CPU usage for this Processor instance during the next interval or during the runtime of the given block. Іf CPU usage on all processors of the system should be measured, it’s better (=faster) to use the CPU.usage method instead.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cpu/processor.rb', line 29 def usage(interval = 1, &block) unless @usage if processor = CPU.usage(interval, &block).find { |p| p.processor_id == processor_id } then @usage = processor.usage end end @usage end |