Slide 32
Slide 32 text
ruby-prof
module AppProfiler
def run
result = RubyProf.profile do
super
end
printer = RubyProf::FlatPrinter.new(result)
File.open('tmp/ruby_prof.txt', 'w') { |file| printer.print(file) }
end
end
FooBatch.prepend AppProfiler
$ bundle exec rails runner 'require "app_profiler"; FooBatch.execute'
$ head -13 tmp/ruby_prof.txt
Measure Mode: wall_time
Thread ID: 70360380996060
Fiber ID: 70360318592320
Total: 0.602138
Sort by: self_time
%self total self wait child calls name
6.55 0.040 0.039 0.000 0.000 16 Mysql2::Client#_query
4.44 0.249 0.027 0.000 0.222 41 *Kernel#require
3.63 0.022 0.022 0.000 0.000 13 #[]
1.99 0.012 0.012 0.000 0.000 7 Module#inspect
1.70 0.010 0.010 0.000 0.000 5939 Symbol#to_s
1.33 0.026 0.008 0.000 0.018 542 *Module#class_eval