class RequireProf::TablePrinter
Constants
- SORTABLE_COLUMNS
Private Instance Methods
print_result()
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 14 def print_result process_result print_table end
print_table()
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 25 def print_table @output << Text::Table.new(head: ["name", "time (ms)", "memory (kb)"], rows: sorted_rows).to_s end
process_nodes(nodes)
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 29 def process_nodes(nodes) nodes.each do |node| unless @processed_nodes.include?(node.name) @processed_nodes.add node.name @rows << [node.name, node.time.round(precision), node.memory] process_nodes node.children end end end
process_result()
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 19 def process_result @processed_nodes = Set.new @rows = [] process_nodes @result.children end
sort()
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 44 def sort column = @options[:sort].to_s SORTABLE_COLUMNS.include?(column) ? column : 'time' end
sorted_rows()
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 39 def sorted_rows column = SORTABLE_COLUMNS.index(sort) + 1 @rows.select { |i| i[column] > threshold}.sort_by { |i| i[column] }.reverse end
threshold()
click to toggle source
# File lib/require_prof/printers/table_printer.rb, line 49 def threshold @options[:threshold] || 0.0 end