def pretty_print(io = $stdout, **options)
      # Handle the special case that Ruby PrettyPrint expects `pretty_print`
      # to be a customized pretty printing function for a class
      return io.pp_object(self) if defined?(PP) && io.is_a?(PP)

      io = File.open(options[:to_file], "w") if options[:to_file]

      color_output = options.fetch(:color_output) { io.respond_to?(:isatty) && io.isatty }
      @colorize = color_output ? Polychrome.new : Monochrome.new

      if options[:scale_bytes]
        total_allocated_output = scale_bytes(total_allocated_memsize)
        total_retained_output = scale_bytes(total_retained_memsize)
      else
        total_allocated_output = "#{total_allocated_memsize} bytes"
        total_retained_output = "#{total_retained_memsize} bytes"
      end

      io.puts "Total allocated: #{total_allocated_output} (#{total_allocated} objects)"
      io.puts "Total retained:  #{total_retained_output} (#{total_retained} objects)"

      if options[:detailed_report] != false
        io.puts
        TYPES.each do |type|
          METRICS.each do |metric|
            NAMES.each do |name|
              scale_data = metric == "memory" && options[:scale_bytes]
              dump "#{type} #{metric} by #{name}", self.send("#{type}_#{metric}_by_#{name}"), io, scale_data
            end
          end
        end
      end

      io.puts
      dump_strings(io, "Allocated", strings_allocated, limit: options[:allocated_strings])
      io.puts
      dump_strings(io, "Retained", strings_retained, limit: options[:retained_strings])

      io.close if io.is_a? File
    end
def pretty_print(io = $stdout, **options)
      # Handle the special case that Ruby PrettyPrint expects `pretty_print`
      # to be a customized pretty printing function for a class
      return io.pp_object(self) if defined?(PP) && io.is_a?(PP)

      io = File.open(options[:to_file], "w") if options[:to_file]

      color_output = options.fetch(:color_output) { io.respond_to?(:isatty) && io.isatty }
      @colorize = color_output ? Polychrome.new : Monochrome.new

      if options[:scale_bytes]
        total_allocated_output = scale_bytes(total_allocated_memsize)
        total_retained_output = scale_bytes(total_retained_memsize)
      else
        total_allocated_output = "#{total_allocated_memsize} bytes"
        total_retained_output = "#{total_retained_memsize} bytes"
      end

      io.puts "Total allocated: #{total_allocated_output} (#{total_allocated} objects)"
      io.puts "Total retained:  #{total_retained_output} (#{total_retained} objects)"

      if options[:detailed_report] != false
        io.puts
        TYPES.each do |type|
          METRICS.each do |metric|
            NAMES.each do |name|
              scale_data = metric == "memory" && options[:scale_bytes]
              dump "#{type} #{metric} by #{name}", self.send("#{type}_#{metric}_by_#{name}"), io, scale_data
            end
          end
        end
      end

      io.puts
      dump_strings(io, "Allocated", strings_allocated, limit: options[:allocated_strings])
      io.puts
      dump_strings(io, "Retained", strings_retained, limit: options[:retained_strings])

      io.close if io.is_a? File
    end
Output the results of the report
 @param [Hash] options the options for output
 @option opts [String] :to_file a path to your log file
 @option opts [Boolean] :color_output a flag for whether to colorize output
 @option opts [Integer] :retained_strings how many retained strings to print
 @option opts [Integer] :allocated_strings how many allocated strings to print
 @option opts [Boolean] :detailed_report should report include detailed information
 @option opts [Boolean] :scale_bytes calculates unit prefixes for the numbers of bytes