class Asciidoctor::Timings

Constants

CLOCK_ID

Public Class Methods

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

Public Instance Methods

convert() click to toggle source
# File lib/asciidoctor/timings.rb, line 33
def convert
  time :convert
end
now() click to toggle source
# File lib/asciidoctor/timings.rb, line 58
def now
  ::Process.clock_gettime CLOCK_ID
end
parse() click to toggle source
# File lib/asciidoctor/timings.rb, line 25
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 21
def read
  time :read
end
read_parse() click to toggle source
# File lib/asciidoctor/timings.rb, line 29
def read_parse
  time :read, :parse
end
read_parse_convert() click to toggle source
# File lib/asciidoctor/timings.rb, line 37
def read_parse_convert
  time :read, :parse, :convert
end
record(key) click to toggle source
# File lib/asciidoctor/timings.rb, line 12
def record key
  @log[key] = (now - (@timers.delete key))
end
start(key) click to toggle source
# File lib/asciidoctor/timings.rb, line 8
def start key
  @timers[key] = now
end
time(*keys) click to toggle source
# File lib/asciidoctor/timings.rb, line 16
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 45
def total
  time :read, :parse, :convert, :write
end
write() click to toggle source
# File lib/asciidoctor/timings.rb, line 41
def write
  time :write
end