what is the difference between both the code ..

I don't see any difference between the code
that is embedded between the system.out's

am I missing something ??

----- Original Message -----
From: "ShriKant Vashishtha" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 14, 2001 4:34 AM
Subject: OffBeat question...Java performance.


> Hi,
>
> I am trying to judge the performance impact of the following Java code.
>
>         String [] arrayStr = new String[20000];
>         System.out.println(System.currentTimeMillis());
>         for(i=0;i<arrayStr.length;i++){
>                     String a="aa";
>         }
>         System.out.println(System.currentTimeMillis());
>
> Output:
> 1008319728796
> 1008319728799
>
>         String [] arrayStr = new String[20000];
>         int length = arrayStr.length;
>         System.out.println(System.currentTimeMillis());
>         for(i=0;i<arrayStr.length;i++){
>             String a="aa";
>         }
>         System.out.println(System.currentTimeMillis());
>
> Output:
> 1008319767200
> 1008319767221
>
> In my view the first code stub should have been faster as in the second
> snippet we are getting an overhead of a instance variable call over an
> String [] object compared to the length already computed in the first
> one. What is happening behind the scene, I am not aware. Could somebody
> please explain.
>
> Thanks,
> -ShriKant
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to