Geertjan's Blog

  • June 1, 2014

Easy Profiling Point Insertion

Geertjan Wielenga
Product Manager

One really excellent feature of NetBeans IDE is its Profiler. What's especially cool is that you can analyze code fragments, that is, you can right-click in a Java file and then choose Profiling | Insert Profiling Point. When you do that, you're able to analyze code fragments, i.e., from one statement to another statement, e.g., how long a particular piece of code takes to execute:


However, right-clicking a Java file and then going all the way down a longish list of menu items, to find "Profiling", and then "Insert Profiling Point" is a lot less easy than right-clicking in the sidebar (known as the glyph gutter) and then setting a profiling point in exactly the same way as a breakpoint:

That's much easier and more intuitive and makes it far more likely that I'll use the Profiler at all. Once profiling points have been set then, as always, another menu item is added for managing the profiling point:

To achieve this, I added the following to the "layer.xml" file:

<folder name="Editors">
<folder name="AnnotationTypes">
<file name="profiler.xml" url="profiler.xml"/>
<folder name="ProfilerActions">
<file name="org-netbeans-modules-profiler-ppoints-ui-InsertProfilingPointAction.shadow">
<attr name="originalFile"
<attr name="position" intvalue="300"/>

Notice that a "profiler.xml" file is referred to in the above, in the same location as where the "layer.xml" file is found. Here is the content:

<!DOCTYPE type PUBLIC '-//NetBeans//DTD annotation type 1.1//EN' 






Only disadvantage is that this registers the profiling point insertion in the glyph gutter for all file types. But that's true for the debugger too, i.e., there's no MIME type specific glyph gutter, instead, it is shared by all MIME types. Little bit confusing that the profiler point insertion can now, in theory, be set for all MIME types, but that's also true for the debugger, even though it doesn't apply to all MIME types. That probably explains why the profiling point insertion can only be done, officially, from the right-click popup menu of Java files, i.e., the developers wanted to avoid confusion and make it available to Java files only. However, I think that, since I'm already aware that I can't set the Java debugger in an HTML file, I'm also aware that the Java profiler can't be set that way as well.

If you find this useful too, you can download and install the NBM from here:


A small bonus tip: how to cause the New Profiling Point dialog to appear in the same way as a breakpoint is set, i.e., by simply clicking in the glyph gutter on a particular line:

        category = "Tools",
        id = "org.netbeans.eppi.GutterPPI"
        displayName = "Unused")
        path = "Editors/text/x-java/GlyphGutterActions",
        position = 400)
public final class GutterPPI extends AbstractAction {
    public GutterPPI() {
        putValue("default-action", true);
    public void actionPerformed(ActionEvent e) {

For details on the above trick:


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.