aspose file tools*
The moose likes Performance and the fly likes Java Profiler with Open API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Java Profiler with Open API" Watch "Java Profiler with Open API" New topic

Java Profiler with Open API

Nemo Cavianini

Joined: Sep 17, 2009
Posts: 6
Hello guys,

I wonder if anyone knows a powerful Java Profiler with support for profiling CPU and memory usage at the level of classes and packages that is open source or provides a proper API.

I have looked into JProfiler, YourKit, JVisualVM, JRockit Mission Control, and a bunch of open source ones. Mission Control and the open source one do not provide enough level of granularity for monitoring, JVisualVM doesn't provide an API to programmatically use it, and JProfiler and YourKit whcih do all I need, are properitary and do not expose APIs (I guess YourKit might have an API, I am playing with it just now, but still it is proprietary).

I wonder if you guys could give me some clue on a Profiler that you might have experience with. Since I would like to use the profiler within the context of OSGi which uses different class loaders for different modules, it occurs with most of the profilers that they get confused because of this multiplicity of class loaders and fail to recognize the proper packages. JProfiler and VisualVM are able to track the objects within the packages and classes of standalone modules, but some like JIP are not able to do so.

Hope I am clear with what I have explained. I highly appreciate any response.


EDIT: I finished playing around with YourKit as well. It seems like it does have an API, but the filtering that it does on running threads only happens at the level of thread names. JVisualVM allows thread executions to be filtered based on methods, classes, and packages used in a thread which is a lot more fine-grained. Does anybody know any tool or API that would give me that level of freedom?
Peter Johnson

Joined: May 14, 2008
Posts: 5823

Both NetBeans and Eclipse have profilers, perhaps one of those would fit your requirements.

JBoss In Action
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 860
Sounds like you want a profiler that profiles out of the box and also allows you to customize it. jamon has the API part and the methods are pretty simple. It also has out of the box monitoring capabilities though it doesn't do cpu and memory out of the box. Out of the box it monitors SQL, web pages, log4j and a few other high level things. It really is a monitoring API. For time based measuring you use the 'start' method, and for tracking other types of numbers (such as cpu and memory) you can use the add method.

There are other tools that have built in support for memory and cpu profiling. Also, you could google the word 'probe'. I think that is a bit of a synonym for API. I haven't used it, but has an api plus good out of the box capabilities. It is not open source. Also check other leading tools like optimizeit and see if they have an API. - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Nemo Cavianini

Joined: Sep 17, 2009
Posts: 6
Thanks guys for the replies.

I have played with profilers that Eclipse and NetBeans offer. Also I have used JAMon in a different project. What I need here is somewhat different though. JAMon requires me to have access to the source code, whereas I need a profiler that enables profiling at the level of byte code and through bytecode rewriting. It is the API for such a profiler that I would like to extend in order to make it work with my own code.

YourKit is somewhat close to what I am looking for. It allows profiling to happen for a code running on a certain JVM. so in case of OSGi, I can get one service to use YourKit in order to monitor the behavior of other bundles running within the OSGi container. Assuming that the bundles I am going to monitor are proprietary and that I don't have access to them, my service should still be able to provide the extra profiling of resources that I require.

YourKit's API is however limited compared to JVisualVM and its capabilities. so I wonder if anybody knows of any other API that would allow me to perform a more fine-grained analysis of a third party java code from my written code.

Hope I am clearer this time.
I agree. Here's the link:
subject: Java Profiler with Open API