Ruby Shaper

I am creating a heavy script that parses and saves data, and I really need to know which lines of my code consume most of the time. Does Rubymine have profiling features, or maybe you can somehow add a profiler to it?

+6
source share
2 answers

I also looked for him, but to no avail. If you find something, let me know.

Meanwhile ... There are two modules in Ruby itself that could help you.

Benchmark - http://apidock.com/ruby/Benchmark

You do something like this

require 'benchmark' n = 50000 Benchmark.bm(7) do |x| x.report("for:") { for i in 1..n; a = "1"; end } x.report("times:") { n.times do ; a = "1"; end } x.report("upto:") { 1.upto(n) do ; a = "1"; end } end 

and this will give you a good profiling table

  user system total real for: 1.050000 0.000000 1.050000 ( 0.503462) times: 1.533333 0.016667 1.550000 ( 0.735473) upto: 1.500000 0.016667 1.516667 ( 0.711239) 

Profiler __ - http://apidock.com/ruby/Profiler__

The easiest way to use this module is to simply require 'profile' , and after the script finishes, it returns data about each call.

Check out this example http://ruby.about.com/od/advancedruby/a/profile.htm

+2
source

Starting with version 2019.1, RubyMine supports profiling using RbSpy: https://www.jetbrains.com/help/ruby/cpu-profiler.html

0
source

All Articles