How long does a line of Java code execute?

Image by HowardWilks from Pixabay

You may wonder how long a particular line of Java code executes. If this line is part of your code, it’s easy to find out by putting System.currentTimeMillis() calls before and after the line and finding the difference. But what if this line of code is part of a library or a framework? You could use a profiler, but a quicker and easier way might be to use breakpoints in IDEA.