#!/usr/bin/env ruby PULS_THRESHOLD = 100 if ARGV.size < 1 then puts "#{__FILE__} target_log [modification_script]" exit end PROCESS = ARGV[1] ? ARGV[1] : false STDERR.puts "Process? : #{PROCESS}" if PROCESS then modifier_list = [] line_index = 0 open(ARGV[1]).each{|line| if line !~ /^\s*(\d+),\s*([+-]?\d+)/ then STDERR.puts "Format Error!!" STDERR.puts "#{line_index} : #{line}" exit end modifier_list << [$1.to_i, $2.to_i] line_index += 1 } modifier = 0 line_index = 0 open(ARGV[0]).each{|line| if modifier_list[0] and (modifier_list[0][0] == line_index) then modifier = (modifier_list.shift)[1] end if line =~ /^A\s+(\d+)\s/ then t_str = sprintf("%11d", $1.to_i + modifier) line.gsub!(/^A\s+\d+\s/, "A#{t_str} ") end print line line_index += 1 } else before_time = 0 modified = 0 line_index = 0 open(ARGV[0]).each{|line| if line =~ /^A\s+(\d+)\s/ then t = $1.to_i if t < before_time then if modified == 0 then puts sprintf("%8d, %11d : - %11d %11d", line_index, (before_time - t + 10), before_time, t) end modified = t elsif modified > 0 then puts sprintf("%8d, %11d : + %11d %11d", line_index, 0, modified, t) modified = 0 before_time = t else if t - before_time > 10 then puts sprintf("%8d, %11d : + %11d %11d", line_index, (t - before_time) > PULS_THRESHOLD ? (before_time - t) + 10 : 0, before_time, t) end before_time = t end end line_index += 1 } end