Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: How can I see what parts of my code are running the most? (profiling)

I am writing a simple checkers game in Java. When I mouse over the board my processor ramps up to 50% (100% on a core).

I would like to find out what part of my code(assuming its my fault) is executing during this.

I have tried debugging, but step-through debugging doesn't work very well in this case.

Is there any tool that can tell me where my problem lies? I am currently using Eclipse.

like image 272
jjnguy Avatar asked Sep 18 '08 05:09

jjnguy


People also ask

What is code profiling in Java?

Profiling is the process of examining an application to locate memory or performance-related issues. When profiling a Java application, you can monitor the Java Virtual Machine (JVM) and obtain data about application performance, including method timing, object allocation and garbage collection.

What is JProfiler used for?

JProfiler is a Java profiler tool and is useful for developers/testers as it can be used to analyze performance bottlenecks, memory leaks, CPU loads, and to resolve threading issues. JProfiler works both as a stand-alone application and as a plug-in for the Eclipse software development environment.

How to Profile Java application in IntelliJ?

To profile them, select the necessary configuration, click the clock icon in the top toolset pane, and select the desired profiling option: Async Profiler or Java Flight Recorder. These were the most useful and powerful features that IntelliJ IDEA offers for profiling Java applications.


2 Answers

This is called "profiling". Your IDE probably comes with one: see Open Source Profilers in Java.

like image 59
John Millikin Avatar answered Nov 02 '22 07:11

John Millikin


Use a profiler (e.g yourkit )

like image 31
Ran Biron Avatar answered Nov 02 '22 07:11

Ran Biron