views:

185

answers:

6

I need to find out the time a function takes for computing the performance of the application / function. is their any open source Java APIs for doing the same ?

+1  A: 

Take a look at the official TPTP plugin for Eclipse. This pretty much does all you describe and a (frikkin') whole lot more. I can really recommend it.

Epaga
+4  A: 

You're in luck as there are quite a few open source Java profilers available for you.

Ovid
+1  A: 

I don't know if there are APIS, but you normally use the funciton currenttimemillis for that... You measure the time at the beggining, then again at the end of the execution and voila!!! you got your time substracting

pabloh84
for very, very simple stuff, stuff, this can work great, I agree. Not so great for compicated software.
Epaga
What is "very, very simple stuff, stuff"?
Andre Bossard
I thought this depended on your Operating System. I seem to remember that the windows clock only has a resolution of 5 milliseconds.I know that's small, but for something that you're trying to tune to be as fast as possible it could be an issue....
Aidos
A: 

Hiperic provide a GPLv2 licenced tool for monitoring all sort of system resources called SIGAR (System Information Gatherer and Reporter).

This tool is used to provide things like adaptive load balancing in GridGain (a grid computing framework).

http://www.hyperic.com/products/sigar.html

Aidos
A: 

Have a look to this question : Which java profiling tool do you use and which tool you think is the best ?

Barth
A: 

If it's just one function you care about, wrap a million-iteration loop around it, and time it with a stopwatch. Then seconds translate to microseconds.

On the other hand, if you want to speed it up, all you need is this.

Mike Dunlavey