Remove totals in profile table properly (#9186)

Merge pull request 9186
This commit is contained in:
Ashwin Maroli 2022-12-18 18:44:02 +05:30 committed by GitHub
parent d78c65f2c7
commit 82bb2714df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 15 deletions

View File

@ -15,16 +15,12 @@ module Jekyll
private private
# rubocop:disable Metrics/AbcSize
def data_for_table(num_of_rows) def data_for_table(num_of_rows)
sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] } sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] }
sorted = sorted.slice(0, num_of_rows) sorted = sorted.slice(0, num_of_rows)
table = [header_labels] table = [header_labels]
totals = Hash.new { |hash, key| hash[key] = 0 }
sorted.each do |filename, file_stats| sorted.each do |filename, file_stats|
GAUGES.each { |gauge| totals[gauge] += file_stats[gauge] }
row = [] row = []
row << filename row << filename
row << file_stats[:count].to_s row << file_stats[:count].to_s
@ -33,14 +29,8 @@ module Jekyll
table << row table << row
end end
footer = [] table
footer << "TOTAL (for #{sorted.size} files)"
footer << totals[:count].to_s
footer << format_bytes(totals[:bytes])
footer << format("%.3f", totals[:time])
table << footer
end end
# rubocop:enable Metrics/AbcSize
def header_labels def header_labels
GAUGES.map { |gauge| gauge.to_s.capitalize }.unshift("Filename") GAUGES.map { |gauge| gauge.to_s.capitalize }.unshift("Filename")

View File

@ -33,18 +33,14 @@ module Jekyll
def profile_process def profile_process
profile_data = { "PHASE" => "TIME" } profile_data = { "PHASE" => "TIME" }
total_time = 0
[:reset, :read, :generate, :render, :cleanup, :write].each do |method| [:reset, :read, :generate, :render, :cleanup, :write].each do |method|
start_time = Time.now start_time = Time.now
@site.send(method) @site.send(method)
end_time = (Time.now - start_time).round(4) end_time = (Time.now - start_time).round(4)
profile_data[method.to_s.upcase] = format("%.4f", end_time) profile_data[method.to_s.upcase] = format("%.4f", end_time)
total_time += end_time
end end
profile_data["TOTAL TIME"] = format("%.4f", total_time)
Jekyll.logger.info "\nBuild Process Summary:" Jekyll.logger.info "\nBuild Process Summary:"
Jekyll.logger.info Profiler.tabulate(Array(profile_data)) Jekyll.logger.info Profiler.tabulate(Array(profile_data))