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
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
# File lib/asciidoctor/timings.rb, line 49 def print_report to = $stdout, subject = nil to.puts %(Input file: #{subject}) if subject to.puts %( Time to read and parse source: #{'%05.5f' % read_parse.to_f}) to.puts %( Time to convert document: #{'%05.5f' % convert.to_f}) to.puts %( Total time (read, parse and convert): #{'%05.5f' % read_parse_convert.to_f}) end
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
Private Instance Methods
now()
click to toggle source
# File lib/asciidoctor/timings.rb, line 60 def now ::Process.clock_gettime CLOCK_ID end