If you're using the Eclipse plugin, then select compile button from
the toolbar and you'll find the output option on the compile options
dialog.  The resulting output files will show more readable
javascript.



On Dec 15, 6:58 pm, "[email protected]" <[email protected]>
wrote:
> Well i just ran test i not sure how to compile out differently but it
> seems like for each loop is slow.
>
> --------- For Each Loop -------
>
> Start: 1260903435636
> End: 1260903435648
> ForEach - Elapsed time in milliseconds: 12
>
> -------END-------
>
> --------- Iterator Loop -------
>
> Start: 1260903435648
> End: 1260903435656
> Iterator - Elapsed time in milliseconds: 8
>
> -------END-------
>
> --------- For Loop --------
>
> Start: 1260903435656
> End: 1260903435662
> For - Elapsed time in milliseconds: 6
>
> -------END-------
>
> --------- While Loop -------
>
> Start: 1260903435662
> End: 1260903435668
> While - Elapsed time in milliseconds: 6
>
> -------END-------
>
> Using the code
>
> [code]
> package com.ottocap.NewWorkFlow.client.Widget;
>
> import java.util.Arrays;
> import java.util.Date;
> import java.util.Iterator;
> import java.util.List;
>
> public class ArrayToList {
>   public ArrayToList() {
>
>           String sArray[] = createArray();
>
>           //convert array to list
>           List lList = Arrays.asList(sArray);
>
>           System.out.println("\n--------- For Each Loop -------\n");
>           long lForEachStartTime = new Date().getTime();
>           System.out.println("Start: " + lForEachStartTime);
>
>           //for loop
>           for (Object thestring: lList){
>                   String stemp = (String)thestring;
>           }
>
>           long lForEachEndTime = new Date().getTime();
>           System.out.println("End: " + lForEachEndTime);
>
>           long lForEachDifference = lForEachEndTime - lForEachStartTime;
>           System.out.println("ForEach - Elapsed time in milliseconds: " +
> lForEachDifference);
>
>           System.out.println("\n-------END-------");
>
>           System.out.println("\n--------- Iterator Loop -------\n");
>           long lIteratorStartTime = new Date().getTime();
>           System.out.println("Start: " + lIteratorStartTime);
>
>           //iterator loop
>           Iterator<String> iterator = lList.iterator();
>           while ( iterator.hasNext() ){
>               String stemp = iterator.next();
>           }
>           long lIteratorEndTime = new Date().getTime();
>           System.out.println("End: " + lIteratorEndTime);
>
>           long lIteratorDifference = lIteratorEndTime - lIteratorStartTime;
>           System.out.println("Iterator - Elapsed time in milliseconds: " +
> lIteratorDifference);
>
>           System.out.println("\n-------END-------");
>
>           System.out.println("\n--------- For Loop --------\n");
>           long lForStartTime = new Date().getTime();
>           System.out.println("Start: " + lForStartTime);
>
>           //for loop
>           for (int i=0; i< lList.size(); i++){
>                   String stemp = (String)lList.get(i);
>           }
>
>           long lForEndTime = new Date().getTime();
>           System.out.println("End: " + lForEndTime);
>
>           long lForDifference = lForEndTime - lForStartTime;
>           System.out.println("For - Elapsed time in milliseconds: " +
> lForDifference);
>
>           System.out.println("\n-------END-------");
>
>           System.out.println("\n--------- While Loop -------\n");
>           long lWhileStartTime = new Date().getTime();
>           System.out.println("Start: " + lWhileStartTime);
>
>           //while loop
>           int j=0;
>           while (j< lList.size())
>           {
>                   String stemp = (String)lList.get(j);
>                   j++;
>           }
>           long lWhileEndTime = new Date().getTime();
>           System.out.println("End: " + lWhileEndTime);
>
>           long lWhileDifference = lWhileEndTime - lWhileStartTime;
>           System.out.println("While - Elapsed time in milliseconds: " +
> lWhileDifference);
>
>           System.out.println("\n-------END-------");
>
>   }
>
>   static String [] createArray(){
>
>           String sArray[] = new String [150000];
>
>           for(int i=0; i<150000; i++)
>                   sArray[i] = "Array " + i;
>
>           return sArray;
>   }}
>
> [/code]
>
> On Dec 15, 10:43 am, Chris Lowe <[email protected]> wrote:
>
>
>
> > You could try compiling with the Pretty or Detailed options and
> > examine the javascript?
>
> > On Dec 15, 6:29 pm, "[email protected]" <[email protected]>
> > wrote:
>
> > > Just wondering what is a better way to code. Using for each loops or
> > > for loops?
>
> > > I am wondering will the resulting javascript be different.

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to