Skip to content

Commit

Permalink
Remove totals in profile table properly (#9186)
Browse files Browse the repository at this point in the history
Merge pull request 9186
  • Loading branch information
ashmaroli committed Dec 18, 2022
1 parent d78c65f commit 82bb271
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
12 changes: 1 addition & 11 deletions lib/jekyll/liquid_renderer/table.rb
Expand Up @@ -15,16 +15,12 @@ def to_s(num_of_rows = 50)

private

# rubocop:disable Metrics/AbcSize
def data_for_table(num_of_rows)
sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] }
sorted = sorted.slice(0, num_of_rows)

table = [header_labels]
totals = Hash.new { |hash, key| hash[key] = 0 }

sorted.each do |filename, file_stats|
GAUGES.each { |gauge| totals[gauge] += file_stats[gauge] }
row = []
row << filename
row << file_stats[:count].to_s
Expand All @@ -33,14 +29,8 @@ def data_for_table(num_of_rows)
table << row
end

footer = []
footer << "TOTAL (for #{sorted.size} files)"
footer << totals[:count].to_s
footer << format_bytes(totals[:bytes])
footer << format("%.3f", totals[:time])
table << footer
table
end
# rubocop:enable Metrics/AbcSize

def header_labels
GAUGES.map { |gauge| gauge.to_s.capitalize }.unshift("Filename")
Expand Down
4 changes: 0 additions & 4 deletions lib/jekyll/profiler.rb
Expand Up @@ -33,18 +33,14 @@ def initialize(site)

def profile_process
profile_data = { "PHASE" => "TIME" }
total_time = 0

[: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)
total_time += end_time
end

profile_data["TOTAL TIME"] = format("%.4f", total_time)

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

Expand Down

0 comments on commit 82bb271

Please sign in to comment.