Sha256: 1a81a39692a92934681c4cd0657741a0d8c9b0e7f2854288d47e8a073ed6886c

Contents?: true

Size: 1.67 KB

Versions: 31

Compression:

Stored size: 1.67 KB

Contents

# encoding: utf-8

module RubyProf
  # Helper class to simplify printing profiles of several types from
  # one profiling run. Currently prints a flat profile, a callgrind
  # profile, a call stack profile and a graph profile.
  class MultiPrinter
    def initialize(result)
      @stack_printer = CallStackPrinter.new(result)
      @graph_printer = GraphHtmlPrinter.new(result)
      @tree_printer = CallTreePrinter.new(result)
      @flat_printer = FlatPrinter.new(result)
    end

    # create profile files under options[:path] or the current
    # directory. options[:profile] is used as the base name for the
    # pofile file, defaults to "profile".
    def print(options)
      @profile = options.delete(:profile) || "profile"
      @directory = options.delete(:path) || File.expand_path(".")
      File.open(stack_profile, "w") do |f|
        @stack_printer.print(f, options.merge(:graph => "#{@profile}.graph.html"))
      end
      File.open(graph_profile, "w") do |f|
        @graph_printer.print(f, options)
      end
      File.open(tree_profile, "w") do |f|
        @tree_printer.print(f, options)
      end
      File.open(flat_profile, "w") do |f|
        @flat_printer.print(f, options)
      end
    end

    # the name of the call stack profile file
    def stack_profile
      "#{@directory}/#{@profile}.stack.html"
    end

    # the name of the graph profile file
    def graph_profile
      "#{@directory}/#{@profile}.graph.html"
    end

    # the name of the callgrind profile file
    def tree_profile
      "#{@directory}/#{@profile}.grind.dat"
    end

    # the name of the flat profile file
    def flat_profile
      "#{@directory}/#{@profile}.flat.txt"
    end

  end
end

Version data entries

31 entries across 29 versions & 3 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/ruby-prof-0.15.9/lib/ruby-prof/printers/multi_printer.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/ruby-prof-0.15.1/lib/ruby-prof/printers/multi_printer.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/ruby-prof-0.15.1/lib/ruby-prof/printers/multi_printer.rb
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/ruby-prof-0.15.1/lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.9 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.8 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.7 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.6 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.5 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.4 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.3 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.2 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.1 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.15.0 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.14.2 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.14.1 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.14.0 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.13.1 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.13.0 lib/ruby-prof/printers/multi_printer.rb
ruby-prof-0.12.2 lib/ruby-prof/printers/multi_printer.rb