my dog learned polymorphism*
The moose likes Beginning Java and the fly likes How i get execution time in java??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How i get execution time in java???" Watch "How i get execution time in java???" New topic
Author

How i get execution time in java???

Muhammad usman shad
Ranch Hand

Joined: Jan 06, 2010
Posts: 30
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

Joined: Oct 25, 2008
Posts: 2700

Look at java.lang.System.currentTimeMillis() and build something around it.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Costi Ciudatu
Ranch Hand

Joined: Oct 24, 2006
Posts: 74
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

Joined: Oct 27, 2005
Posts: 19651
    
  18

And if milliseconds is not accurate enough, Java 5.0 added System.nanoTime() which returns the time in nanoseconds.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How i get execution time in java???
 
Similar Threads
finding the timeofday in Java
Performance meseaurement of code conatining queries
Processing Time
Timing a program
Calculating Time taken by a code segment