LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   how to start timing and print the timing result on portions of java codes ?? (http://www.linuxquestions.org/questions/programming-9/how-to-start-timing-and-print-the-timing-result-on-portions-of-java-codes-444723/)

alred 05-14-2006 01:20 PM

how to start timing and print the timing result on portions of java codes ??
 
how to insert timer within java code , for example ...

Code:

timerStart(); //probably set to zero or ...

docall(s1 , i1 , i2);

print(timerStop()); //probably returning a deducted result

i donno , but the timing part doesnt need to be highly precise but fine enough for some general use , not necessarily must they be called as a timing function ...

links to example code welcome ...

//thanks in advance ...


.

psiteddy 05-14-2006 06:21 PM

are you looking for

System.currentTimeMillis(), or
System.nanoTime()?

i can't post a link to the javadoc because im not allowed, but it is in System (obviously).

the example code given there is...

Code:

long startTime = System.nanoTime();
// ... the code being measured ...
long estimatedTime = System.nanoTime() - startTime;


alred 05-15-2006 10:00 AM

thanks ... those lines really work great for my general needs ...

//sorry for my laziness , actually i was kind of onto this tcl , so no java/pascal during that moment but i just need a java live doc ...

//great ...


.


All times are GMT -5. The time now is 11:39 AM.