Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How i get execution time in java???

 
Muhammad usman shad
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assalam o Aliekum to all,

Dears,
I am assigned a task by my teacher in java in which i am sorting an array using different sortin techniques.

I do it accurately...

But,

Now i have to get the Execution time from the system which it takes to get the output,

Is there any method in java which can do this and if not then can i do it???

If yes,

Then please please help me,
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at java.lang.System.currentTimeMillis() and build something around it.
 
Costi Ciudatu
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you simply instantiate a java.util.Date object with the default constructor (new Date()) that will reflect the current time.
The same applies to java.util.Calendar.getInstance().
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if milliseconds is not accurate enough, Java 5.0 added System.nanoTime() which returns the time in nanoseconds.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic