class Object
Public Instance Methods
format(obj)
click to toggle source
# File lib/straces.rb, line 97 def format(obj) [ obj[:time].round(4).to_s.ljust(6, "0"), obj[:timing].round(6).to_s.ljust(8, "0"), obj[:call].ljust(16), obj[:middle], ].join(" ") end
process(lines, syscalls_ignored, syscalls_focused)
click to toggle source
# File lib/straces.rb, line 76 def process(lines, syscalls_ignored, syscalls_focused) last_obj = { time: 0.0 } objs = lines.map do |line| obj = strace_parse(line) next unless obj if syscalls_focused.length > 0 next unless syscalls_focused.include? obj[:call] end next if syscalls_ignored.include? obj[:call] obj[:time] = obj[:timing] + last_obj[:time] last_obj = obj obj end objs.compact end
strace_parse(line)
click to toggle source
# File lib/straces.rb, line 40 def strace_parse(line) return nil if line.end_with? "<unfinished ...>" return nil if line.end_with? "resumed>) = ?" return nil if line.end_with? "+++ exited with 0 +++" # accept4(3, return nil if line.end_with? ", " return nil if line.end_with? "<detached ...>" p line if ENV['STRACES_DEBUG'] == "yes" matcher = line.match /^(?<pid>\d*)\s?(?<time>\d\d:\d\d:\d\d\.?\d*)?\s?(?<interrupted>\<\.\.\.)?(?<call>[^\(]+)(?<middle>.*)?\<(?<timing>\d+\.\d+)\>$/ #63796 11:18:12 clock_gettime(CLOCK_MONOTONIC, {tv_sec=27510, tv_nsec=693534954}) = 0 <0.000108> #63796 11:18:12 <... clock_gettime resumed> {tv_sec=27510, tv_nsec=648632454}) = 0 <0.000356> call, middle = if matcher[:interrupted] syscall, rest = matcher[:call].split(" ") [syscall, rest] else [matcher[:call], matcher[:middle]] end timing = Float matcher[:timing] rescue 0.0 if matcher { pid: matcher[:pid], call: call, middle: middle, timing: timing } else nil end end