class Jekyll::Profiler

Constants

TERMINAL_TABLE_STYLES

Public Class Methods

new(site) click to toggle source
# File lib/jekyll/profiler.rb, line 30
def initialize(site)
  @site = site
end
tabulate(table_rows) click to toggle source
# File lib/jekyll/profiler.rb, line 12
def self.tabulate(table_rows)
  require "terminal-table"

  rows   = table_rows.dup
  header = rows.shift
  output = +"\n"

  table = Terminal::Table.new do |t|
    t << header
    t << :separator
    rows.each { |row| t << row }
    t.style = TERMINAL_TABLE_STYLES
    t.align_column(0, :left)
  end

  output << table.to_s << "\n"
end

Public Instance Methods

profile_process() click to toggle source
# File lib/jekyll/profiler.rb, line 34
def profile_process
  profile_data = { "PHASE" => "TIME" }

  [:reset, :read, :generate, :render, :cleanup, :write].each do |method|
    start_time = Time.now
    @site.send(method)
    end_time = (Time.now - start_time).round(4)
    profile_data[method.to_s.upcase] = format("%.4f", end_time)
  end

  Jekyll.logger.info "\nBuild Process Summary:"
  Jekyll.logger.info Profiler.tabulate(Array(profile_data))

  Jekyll.logger.info "\nSite Render Stats:"
  @site.print_stats
end