How to differentiate between static and instance methods using YourKit Java Profiler?

Questions about YourKit Java Profiler
Post Reply
Volodya Lombrozo
Posts: 2
Joined: Tue May 23, 2023 7:52 am

How to differentiate between static and instance methods using YourKit Java Profiler?

Post by Volodya Lombrozo »

I'm currently using YourKit Java Profiler to gather information about the total number of invoked methods during profiling. However, I'm facing difficulty in distinguishing between static methods and instance methods.

When I perform CPU profiling (tracing https://www.yourkit.com/docs/java/help/tracing.jsp), I obtain a list of methods, but there seems to be no apparent way to identify whether a method is static or instance-based. For instance, here are two sample entries from the method list:

- Instance: java.lang.String.charAt(int) String.java
- Static: java.lang.String.lastIndexOf(byte[], byte, int, String, int) String.java

Both methods appear identical and lack any indication of their type (static or instance). I have extensively searched through the official documentation provided by YourKit, but have been unable to find any relevant information on this matter.

Is it possible to differentiate between static and instance methods during profiling using YourKit? If so, what approach or feature should I utilize to achieve this? I would greatly appreciate any insights or guidance regarding this issue.

By the way, I've asked the same question on SO: https://stackoverflow.com/questions/763 ... -java-prof
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Re: How to differentiate between static and instance methods using YourKit Java Profiler?

Post by Vladimir Kondratyev »

Dear Volodya,

The profiler does not mark static methods in any way. Usually it is not necessary for optimization tasks. Could you please explain why you need this and how you will use it.

Best regards,
Vladimir Kondratyev
YourKit GmbH
http://www.yourkit.com
"Don't get lost in data, get information!"
Volodya Lombrozo
Posts: 2
Joined: Tue May 23, 2023 7:52 am

Re: How to differentiate between static and instance methods using YourKit Java Profiler?

Post by Volodya Lombrozo »

Dear Vladimir Kondratyev.

I’m using YourKit profiler not only for optimisation tasks, but also for investigation and statistical tasks too. For example, I want to answer the next questions about some applications:

1. How many static methods was invoked during profiling period on the running application?
2. How many instance methods was invoked during profiling period in runtime?
3. How many constructor was invoked?
4. How much time we spent in static/instance methods and constructors?
5. Is a method was invoked on “interface” variable or on a “concrete” class variable. Did the dynamic dispatch happen?
6. etc

Actually, it is a lot of statistics that we can gather about application behaviour which can help us to judge about an application architecture, behaviour and runtime patterns.

Currently, I just perform CPU profiling (tracing) then export all gathered data into CSV, then I download an application sources that was profiled and parse them. Then I try to match results from CSV with the information from sources and, of course, I have some percent of “not found methods”. I still have problems with parsing lambdas, anonymous and inner classes, moreover the version of sources and real profiling application could be different.

Hence, the feature would greatly help me investigate all that questions. If you don’t have such a feature, maybe I can help to implement it somehow? Do you have some partly open sources, or some plugin system?
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Re: How to differentiate between static and instance methods using YourKit Java Profiler?

Post by Vladimir Kondratyev »

Dear Volodya,

I see your point, and I've added corresponded feature requests. But I can't promise any dates when these features will be implemented.

P.S. Regarding #5 : all methods in Java are virtual, and dynamic dispatch always happens (for all non-static) methods.

Best regards,
Vladimir Kondratyev
YourKit GmbH
http://www.yourkit.com
"Don't get lost in data, get information!"
Post Reply