class RaccProfiler

Public Class Methods

new(really) click to toggle source
# File bin/racc, line 276
def initialize(really)
  @really = really
  @log = []
end

Public Instance Methods

report() click to toggle source
# File bin/racc, line 293
def report
  return unless @really
  f = $stderr
  total = cumulative_time()
  f.puts '--task-----------+--sec------+---%-'
  @log.each do |name, time|
    f.printf "%-19s %s %3d%%\n", name, pjust(time,4,4), (time/total*100).to_i
  end
  f.puts '-----------------+-----------+-----'
  f.printf "%-20s%s\n", 'total', pjust(total,4,4)
end
section(name) { || ... } click to toggle source
# File bin/racc, line 281
def section(name)
  if @really
    t1 = ::Process.times.utime
    result = yield
    t2 = ::Process.times.utime
    @log.push [name, t2 - t1]
    result
  else
    yield
  end
end