Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

profiler in rubymine

I creating heavy script which analize and store the data and I'm really need to know which lines of my code consuming most of the time. Is Rubymine have profiler features or maybe it possible to add profiler to it somehow?

like image 850
silent_coder Avatar asked Feb 17 '13 02:02

silent_coder


People also ask

How to use profiler in IntelliJ?

It is easy to start profiling your application – just open the Profiler tool window from the bottom toolbar, select a running process, and right-click it to choose which profiler to attach. You can then stop profiling and see the results in the same tool window.

Does IntelliJ have a profiler?

For CPU and allocation profiling, IntelliJ IDEA provides integration with the following profilers: Java Flight Recorder – a standard profiling tool shipped as part of the JDK. Async Profiler – a very accurate profiler that can also collect native call and memory allocation data.

How do I enable IntelliJ profiler?

Go to Settings/Preferences | Build, Execution, Deployment | Java Profiler. Click Add New Configuration and select the profiler. Modify the profiler options as required.

How do you read profiler data?

The profiling data is grouped by thread. You can select to view merged data for the entire process (All threads merged) or select a specific thread for closer investigation. The threads are listed on the left-hand side of the Profiler tool window and sorted by the number of collected samples.


2 Answers

I was looking for it also, but without success. If you find something, please let me know.

Meanwhile... In Ruby itself there are two modules which 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 it will give you nice table of profiling results

             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__

Easiest way to use this module is just require 'profile' and after your script finish it blow out data about each call.

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

like image 120
Mailo Světel Avatar answered Nov 03 '22 13:11

Mailo Světel


Since the 2019.1 version, RubyMine supports profiling using RbSpy. To profile a script:

  1. (Optional) Configure the profiler settings on the Settings/Preferences | Build, Execution, Deployment | Ruby Profiler page.
  2. Right-click the script in the editor or Project view, and select Run 'script name' with 'RbSpy profiler'.

  3. Analyze results in the Profiler tool window. The Flame Chart tab shows you the state of the call stack at any moment of time. Each frame represents a method/block in the stack (a stack frame). On the Y-axis, there is a stack depth going from bottom up. The X-axis shows the stack sorted from the most time-consuming methods/blocks to the least consuming ones.

You can learn more from the Profile applications help topic.

like image 38
Andrey Aksyonov Avatar answered Nov 03 '22 15:11

Andrey Aksyonov