Last time someone mentioned profiling tools. So let’s talk about code-level profiling tools. No matter how you blow it, code-level profiling tools take a toll on performance itself. And the loss is not small. Even if it is done in the lower layer, there is still a lot of loss. 20-30% loss is normal.

When it comes to finding the right entry point for a code-level tool, it’s definitely not sensible to start with one. Once a specific process or thread has been analyzed, or a specific method of suspicious code has been identified, the code-level profiling tool is more targeted.

JAVA direction: There are many code-level profiling tools for JAVA. JvirtualVM in the Current SUN JDK can see the CPU and memory consumption of a method and object in real time. There are also tools such as JStack/JMap to assist. If you don’t want to see the memory usage in real time, you can also do dump to see the memory usage. But looking at method call times is a little harder. However, there are a number of commercial tools out there, such as JProfiler, which is by far the most comprehensive tool I’ve seen in Java profiling (it’s commercial).

There’s not just a tree structure, there’s a call diagram.

It is recommended that you try to find alternative and suitable open source tools.

C/C++ direction: There are more than just code-level profiling tools in this direction, like ValGrind, Google PerfTools. System-level debugging tools are also available. Various trace tools, such as perf/ SystemTap /oprofile, are also available, and kernel-level tools are less costly. There is Dtrace on Solaris, and the Performance Top book is almost full of examples of Dtrace tools. And these tools can also generate flame maps, heat maps, things like that.

Corresponding profiling tools are also available in other languages. PHP has Xdebug, Xhprof; Python has cProfile, MemoryProfiler, lineprofiler; .NET has CLR profiler; The Go language has pprof (which is a port and has more tools in Google Perf). Almost similar tools exist, regardless of language. With these tools, coupled with system-level debugging tools, finding code-level performance problems is a matter of minutes.

Of course, we should emphasize the importance of people’s thinking ability in social progress. We should never take a hammer to hit a date. The right tool is the most important.