Class: RubyProf::MultiPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-prof/printers/multi_printer.rb

Overview

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.

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ MultiPrinter

Returns a new instance of MultiPrinter.



8
9
10
11
12
13
# File 'lib/ruby-prof/printers/multi_printer.rb', line 8

def initialize(result)
  @stack_printer = CallStackPrinter.new(result)
  @graph_printer = GraphHtmlPrinter.new(result)
  @tree_printer = CallTreePrinter.new(result)
  @flat_printer = FlatPrinter.new(result)
end

Instance Method Details

#flat_profileObject

the name of the flat profile file



51
52
53
# File 'lib/ruby-prof/printers/multi_printer.rb', line 51

def flat_profile
  "#{@directory}/#{@profile}.flat.txt"
end

#graph_profileObject

the name of the graph profile file



41
42
43
# File 'lib/ruby-prof/printers/multi_printer.rb', line 41

def graph_profile
  "#{@directory}/#{@profile}.graph.html"
end

create profile files under options or the current directory. options is used as the base name for the pofile file, defaults to “profile”.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ruby-prof/printers/multi_printer.rb', line 18

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

#stack_profileObject

the name of the call stack profile file



36
37
38
# File 'lib/ruby-prof/printers/multi_printer.rb', line 36

def stack_profile
  "#{@directory}/#{@profile}.stack.html"
end

#tree_profileObject

the name of the callgrind profile file



46
47
48
# File 'lib/ruby-prof/printers/multi_printer.rb', line 46

def tree_profile
  "#{@directory}/#{@profile}.grind.dat"
end