class Asciidoctor::Timings

Constants

CLOCK_ID

Public Class Methods

new() click to toggle source
# File lib/asciidoctor/timings.rb, line 4
def initialize
  @log = {}
  @timers = {}
end

Public Instance Methods

convert() click to toggle source
# File lib/asciidoctor/timings.rb, line 34
def convert
  time :convert
end
parse() click to toggle source
# File lib/asciidoctor/timings.rb, line 26
def parse
  time :parse
end
print_report(to = $stdout, subject = nil) click to toggle source
read() click to toggle source
# File lib/asciidoctor/timings.rb, line 22
def read
  time :read
end
read_parse() click to toggle source
# File lib/asciidoctor/timings.rb, line 30
def read_parse
  time :read, :parse
end
read_parse_convert() click to toggle source
# File lib/asciidoctor/timings.rb, line 38
def read_parse_convert
  time :read, :parse, :convert
end
record(key) click to toggle source
# File lib/asciidoctor/timings.rb, line 13
def record key
  @log[key] = (now - (@timers.delete key))
end
start(key) click to toggle source
# File lib/asciidoctor/timings.rb, line 9
def start key
  @timers[key] = now
end
time(*keys) click to toggle source
# File lib/asciidoctor/timings.rb, line 17
def time *keys
  time = keys.reduce(0) {|sum, key| sum + (@log[key] || 0) }
  time > 0 ? time : nil
end
total() click to toggle source
# File lib/asciidoctor/timings.rb, line 46
def total
  time :read, :parse, :convert, :write
end
write() click to toggle source
# File lib/asciidoctor/timings.rb, line 42
def write
  time :write
end