Class: StraceLog::Stat::CallCounter

Inherits:
Object
  • Object
show all
Defined in:
lib/strace_log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CallCounter

Returns a new instance of CallCounter.



121
122
123
124
125
# File 'lib/strace_log.rb', line 121

def initialize(path)
  @path = path
  @rename = []
  @counter = {}
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



126
127
128
# File 'lib/strace_log.rb', line 126

def path
  @path
end

#renameObject (readonly)

Returns the value of attribute rename.



126
127
128
# File 'lib/strace_log.rb', line 126

def rename
  @rename
end

Instance Method Details

#count(call) ⇒ Object



128
129
130
131
# File 'lib/strace_log.rb', line 128

def count(call)
  c = (@counter[call.func] ||= Counter.new)
  c.count(call)
end

#eachObject



138
139
140
141
142
# File 'lib/strace_log.rb', line 138

def each
  @counter.keys.map do |func|
    yield [@path,func,*@counter[func].to_a]
  end
end

#rename_as(newpath) ⇒ Object



133
134
135
136
# File 'lib/strace_log.rb', line 133

def rename_as(newpath)
  @rename << @path
  @path = newpath
end