2

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 ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Nrj
  • 6,723
  • 7
  • 46
  • 58
  • Note time when you call the function, then make the difference when the function is finished. No need for a API for this – André Schild Feb 26 '18 at 08:33

6 Answers6

4

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

Ovid
  • 11,580
  • 9
  • 46
  • 76
1

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
  • 38,231
  • 58
  • 157
  • 245
1

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

Pablo Herrero
  • 1,724
  • 5
  • 18
  • 23
  • for very, very simple stuff, stuff, this can work great, I agree. Not so great for compicated software. – Epaga Oct 08 '08 at 08:42
  • What is "very, very simple stuff, stuff"? – Andre Bossard Oct 08 '08 at 09:54
  • 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 Oct 13 '08 at 05:14
0

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
  • 2,753
  • 3
  • 27
  • 31
0

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

Community
  • 1
  • 1
Barth
  • 15,135
  • 20
  • 70
  • 105
0

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
  • 40,059
  • 14
  • 91
  • 135