class ProconBypassMan::Counter
Attributes
label[RW]
previous_table[RW]
table[RW]
Public Class Methods
new(label: )
click to toggle source
# File lib/procon_bypass_man/io_monitor.rb, line 5 def initialize(label: ) self.label = label self.table = {} self.previous_table = {} end
Public Instance Methods
formated_previous_table()
click to toggle source
# File lib/procon_bypass_man/io_monitor.rb, line 27 def formated_previous_table t = previous_table.dup start_function = t[:start_function] || 0 end_function = t[:end_function] || 0 eagain_wait_readable_on_read = t[:eagain_wait_readable_on_read] || 0 eagain_wait_readable_on_write = t[:eagain_wait_readable_on_write] || 0 "(#{(end_function / start_function.to_f * 100).floor(1)}%(#{end_function}/#{start_function}), loss: #{eagain_wait_readable_on_read}, #{eagain_wait_readable_on_write})" end
record(event_name)
click to toggle source
アクティブなバケットは1つだけ
# File lib/procon_bypass_man/io_monitor.rb, line 12 def record(event_name) key = Time.now.strftime("%S").to_i if table[key].nil? self.previous_table = table.values.first self.table = {} table[key] = {} end if table[key][event_name].nil? table[key][event_name] = 1 else table[key][event_name] += 1 end self end