class Asciidoctor::Timings - asciidoctor-1.5.6.2 Documentation

# class Asciidoctor::Timings

### 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 20
    def convert
      @log[:convert] || 0
    end

print_report(to = $stdout, subject = nil) click to toggle source

    # File lib/asciidoctor/timings.rb, line 32
    def print_report to = $stdout, subject = nil
      to.puts %Q(Input file: #{subject}) if subject
      to.puts %Q(  Time to read and parse source: #{'%05.5f' % read_parse.to_f})
      to.puts %Q(  Time to convert document: #{'%05.5f' % convert.to_f})
      to.puts %Q(  Total time (read, parse and convert): #{'%05.5f' % read_parse_convert.to_f})
    end

read_parse() click to toggle source

    # File lib/asciidoctor/timings.rb, line 16
    def read_parse
      (time = (@log[:read] || 0) + (@log[:parse] || 0)) > 0 ? time : nil
    end

read_parse_convert() click to toggle source

    # File lib/asciidoctor/timings.rb, line 24
    def read_parse_convert
      (time = (@log[:read] || 0) + (@log[:parse] || 0) + (@log[:convert] || 0)) > 0 ? time : nil
    end

record(key) click to toggle source

    # File lib/asciidoctor/timings.rb, line 12
    def record key
      @log[key] = (::Time.now - (@timers.delete key))
    end

start(key) click to toggle source

    # File lib/asciidoctor/timings.rb, line 8
    def start key
      @timers[key] = ::Time.now
    end

total() click to toggle source

    # File lib/asciidoctor/timings.rb, line 28
    def total
      (time = (@log[:read] || 0) + (@log[:parse] || 0) + (@log[:convert] || 0) + (@log[:write] || 0)) > 0 ? time : nil
    end