class Autobuild::BuildLogfile
Parse and manipulate the information stored in a build log file (usually in prefix/log/stats.log)
Constants
- Entry
Attributes
Public Class Methods
Source
# File lib/autobuild/build_logfile.rb, line 11 def initialize(entries = Array.new) @entries = entries.dup @by_package = Hash.new entries.each do |e| package = (by_package[e.package] ||= Hash.new(0)) package[e.phase] += e.duration end @by_phase = Hash.new entries.each do |e| package = (by_phase[e.phase] ||= Hash.new(0)) package[e.package] += e.duration end end
Source
# File lib/autobuild/build_logfile.rb, line 42 def self.parse(file) entries = File.readlines(file).map do |line| line = line.strip next if line.empty? cols = line.split(/\s+/) date = cols.shift time = cols.shift start_time = Time.parse("#{date} #{time}") duration = Float(cols.pop) phase = cols.pop package = cols.join(" ") Entry.new(package, phase, start_time, duration) end new(entries) end
Public Instance Methods
Source
# File lib/autobuild/build_logfile.rb, line 26 def diff(other) result = [] by_package.each do |pkg_name, phases| other_phases = other.by_package[pkg_name] next unless other_phases phases.each do |phase, duration| next unless other_phases.key?(phase) other_duration = other_phases[phase] result << Entry.new(pkg_name, phase, nil, other_duration - duration) end end BuildLogfile.new(result) end