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 ?
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.
You're in luck as there are quite a few open source Java profilers available for you.
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
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).
Have a look to this question : Which java profiling tool do you use and which tool you think is the best ?
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.