public class TimeArray
{
public static void main (String args[])
{
int something = 2;
long startTime = System.currentTimeMillis();
for (int i=0, n=Integer.MAX_VALUE; i<n; i++)
{
something =- something;
}
long midTime = System.currentTimeMillis();
for (int i=Integer.MAX_VALUE-1; i>=0; i-)
{
something = -something;
}
long endTime = System.currentTimeMillis();
System.out.println("Increasing Delta: " + (midTime - startTime));
System.out.println("Decreasing Delta: " + (endTime - midTime));
}
}
now if you compile this program means if you want to convert it into byte code ... for this we use " javac TimeArray.java" now the byte code is ready in the form of jvm understanding code . now jvm comes is the role and play its game with machine . it converts this program or deals with this byte code . and for dealing it uses jit compiler
and for it we write " java TimeArray " and the output came in only 5 seconds but if you want to use interpreter in the place of compiler than you can use "java -Djava.compiler="" TimeArray " and the output came in 53 seconds ... this is a beautiful thing wow , i love it ...
thanks tushar .
No comments:
Post a Comment