method
profile_requires
v7.1.3.2 -
Show latest stable
-
0 notes -
Class: Profiler
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
profile_requires()
public
Hide source
# File tools/profile, line 23 def profile_requires GC.start before_rss = `ps -o rss= -p #{Process.pid}`.to_i if mode require "ruby-prof" RubyProf.measure_mode = RubyProf.const_get(mode.upcase) RubyProf.start else Object.instance_eval { include RequireProfiler } end elapsed = Benchmark.realtime { require path } results = RubyProf.stop if mode GC.start after_rss = `ps -o rss= -p #{Process.pid}`.to_i if mode if printer = ARGV.shift puts "RubyProf outputting to stderr with printer #{printer}" RubyProf.const_get("#{printer.to_s.classify}Printer").new(results).print($stdout) elsif RubyProf.const_defined?(:CallStackPrinter) filename = "#{File.basename(path, '.rb')}.#{mode}.html" puts "RubyProf outputting to #{filename}" File.open(filename, "w") do |out| RubyProf::CallStackPrinter.new(results).print(out) end else filename = "#{File.basename(path, '.rb')}.#{mode}.callgrind" puts "RubyProf outputting to #{filename}" File.open(filename, "w") do |out| RubyProf::CallTreePrinter.new(results).print(out) end end end RequireProfiler.stats.each do |file, depth, sec| if sec puts "%8.1f ms %s%s" % [sec * 1000, " " * depth, file] else puts "#{' ' * (13 + depth)}#{file}" end end puts "%8.1f ms %d KB RSS" % [elapsed * 1000, after_rss - before_rss] end