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?
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.
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.
Go to Settings/Preferences | Build, Execution, Deployment | Java Profiler. Click Add New Configuration and select the profiler. Modify the profiler options as required.
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.
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
Since the 2019.1 version, RubyMine supports profiling using RbSpy. To profile a script:
Right-click the script in the editor or Project view, and select Run 'script name' with 'RbSpy profiler'.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With