• Post Reply Bookmark Topic Watch Topic
  • New Topic

source code to find the execution time of a java program  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone have the source code to find the execution time of a java program
 
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"sunny .....", please check your private messages for an important administrative matter. Again.
 
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can change the source code it's quite easy. At the very start of your application you can get the current timestamp using System.currentTimeMillis() or System.nanoTime(), depending on how accurate you want it. Afterwards it's just comparing the current timestamp against that stored value again.

If you can't change the source code you'll have to go native using JNI, and interact with the operating system.
 
Rancher
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll get a report if you use the java -Xprof option that has some timings in it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!