I'm new to Ruby profiling and it seems that ruby-prof is a popular choice. I just installed gem and called my program:
ruby-prof ./my-prog.rb
However, the conclusion is incredibly detailed, as profiling data is included for all Ruby core tools and standard libraries and other gems. For example, the top three lines:
8.79 0.011 0.010 0.000 0.001 3343 *String#% 7.28 0.078 0.009 0.000 0.069 2068 *Array#each 4.93 0.038 0.006 0.000 0.032 1098 *Array#map
This is not very useful information for me, since I already know that my program deals with strings and arrays a lot, and, apparently, these classes have already been optimized from them. I only care about the hot spots in my code.
I tried some other printer modes, for example. -p graph_html and -p call_stack , but they all have the same problem.
I see that ruby-prof supports the removal and simplification of the method:
-x, --exclude regexp exclude methods by regexp (see method elimination) -X, --exclude-file file exclude methods by regexp listed in file (see method elimination) --exclude-common-cycles make common iterators like Integer
but there seems to be no obvious way to get what I really want, it is only profiling data for my code, that is, with the time elapsed inside the code from Ruby core / stdlib, and other gems that are only considered timed out inside my code.
As soon as I see that my code has a foo method, which is a performance bottleneck due to the fact that it is called thousands of times and does not work well, then and only I want to see a breakdown of the time elapsed between my code and core / library, called inside this particular method.
I canβt understand why this is not a standard function, since I would expect that this is all that everyone wants to do: first run your own code, and then when you have run out of things for optimization, potentially start optimizing the gems you use and possibly even a ruby ββcore / stdlib. What am I missing?