dcsimg
How to find execution time of a block of java code?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Chandra_Mouli
Posted On:   Tuesday, January 15, 2002 09:46 PM

Hi, How to get execution time of block of java code. I will give starting line and ending line for a block of code which I have to measure execution time
as inline arguments.

Exaple:

java FindExecutionTime TestingClass 10 20

Where FindExecutionTime is the class file name

TestingClass is the class to be test.

10 is the line number in TesingClass.java to be calculate execution time from here.

20 is the line number in TestingClass.java to be calculate execution time upto here.

Re: How to find execution time of a block of java code?

Posted By:   arun_bp  
Posted On:   Tuesday, January 15, 2002 10:46 PM

Hi,
though i am not finding time to write the full program, i think the following code snippet would help u to build one.


class checktime
{
public static void main(String args[]) throws Exception
{
System.out.println(System.currentTimeMillis());

for(int i=0;i<4;i++)
{
System.out.println("
"+i+"
");
}//for
for(int y=0;y<50000;y++);
System.out.println("out of the second loop
");
System.out.println(System.currentTimeMillis());
}//main
}//checktime



you can convert the milliseconds to seconds and find the time lapse.


u can also write to me at bparun@indiatimes.com



-enjoy!!

arun.
About | Sitemap | Contact