Class: StraceLog::Stat::Counter
- Inherits:
-
Object
- Object
- StraceLog::Stat::Counter
- Defined in:
- lib/strace_log.rb
Instance Attribute Summary collapse
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #count(call) ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ Counter
100 101 102 103 104 105 |
# File 'lib/strace_log.rb', line 100 def initialize @calls = 0 @errors = 0 @time = 0 @size = nil end |
Instance Attribute Details
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
106 107 108 |
# File 'lib/strace_log.rb', line 106 def calls @calls end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
106 107 108 |
# File 'lib/strace_log.rb', line 106 def errors @errors end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
106 107 108 |
# File 'lib/strace_log.rb', line 106 def size @size end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
106 107 108 |
# File 'lib/strace_log.rb', line 106 def time @time end |
Instance Method Details
#count(call) ⇒ Object
108 109 110 111 112 113 |
# File 'lib/strace_log.rb', line 108 def count(call) @calls += 1 @errors += 1 if call.ret == "-1" @time += call.elap.to_f if call.elap @size = (@size||0) + call.size if call.size end |
#to_a ⇒ Object
115 116 117 |
# File 'lib/strace_log.rb', line 115 def to_a [@calls,@errors,"%.6f"%@time,@size] end |