-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathruby-prof.rb
More file actions
24 lines (18 loc) · 799 Bytes
/
ruby-prof.rb
File metadata and controls
24 lines (18 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# RubyProf Flat report
# ruby 12-ruby-prof-flat.rb
# cat ruby_prof_reports/flat.txt
require 'ruby-prof'
require_relative 'task-2-with-argument.rb'
RubyProf.measure_mode = RubyProf::ALLOCATIONS
`head -n #{16000} data_large.txt > data_small.txt`
result = RubyProf.profile do
work("data_small.txt")
end
flat_printer = RubyProf::FlatPrinter.new(result)
flat_printer.print(File.open("ruby_prof_reports/flat.txt", "w+"))
dot_printer = RubyProf::DotPrinter.new(result)
dot_printer.print(File.open('ruby_prof_reports/graphviz.dot', 'w+'))
graph_printer = RubyProf::GraphHtmlPrinter.new(result)
graph_printer.print(File.open("ruby_prof_reports/graph.html", "w+"))
printer_callstack = RubyProf::CallStackPrinter.new(result)
printer_callstack.print(File.open('ruby_prof_reports/callstack.html', 'w+'))