Class: ProcView::Stats

Inherits:
Array
  • Object
show all
Defined in:
lib/procview/stats.rb

Constant Summary collapse

TYPE =
{ other: 0, wait: 1, read: 2, write: 3 }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.newObject



4
5
6
# File 'lib/procview/stats.rb', line 4

def self.new
    super(4, 0.0)
end

Instance Method Details

#acc!(type, duration) ⇒ Object



16
17
18
# File 'lib/procview/stats.rb', line 16

def acc! type, duration
    self[TYPE[type]] += duration
end

#add!(other) ⇒ Object



7
8
9
# File 'lib/procview/stats.rb', line 7

def add!(other)
    self.map!.with_index{|t,i| t += other[i]}
end

#scale!(other) ⇒ Object



10
11
12
# File 'lib/procview/stats.rb', line 10

def scale!(other)
    self.map!{|t| t *= other}
end

#sumObject



13
14
15
# File 'lib/procview/stats.rb', line 13

def sum
    self.reduce(:+)
end