aspose file tools
The moose likes Java in General and the fly likes Java Cookbook :  Performance question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Java Cookbook :  Performance question " Watch "Java Cookbook :  Performance question " New topic
Author

Java Cookbook : Performance question

Alvin chew
Ranch Hand

Joined: Jan 08, 2004
Posts: 834
hi, wondering the Data Structuring with Generics, foreach, and Enumerations , would it improve significant performance result ? say for "foreach" , will this feature perform better and faster as compare ordinary "for" loop ?

thank you !!
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
i think about foreach loop :: it's use to prevent ArrayIndexOutOfBoundException at run time.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8876

I dont see any performance improving because of "enhanced" for loop.


Groovy
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
I severely doubt you would. After all the generated bytecode is supposed to be identical to the 1.4 bytecode format.
Any improved performance would therefore be only because the engineers creating the code that effectively creates a traditional for-loop out of the new one create more efficient Java code than you do yourself.
Since there's not much efficiency that can be gained out of for (Iterator i=l.iterator();i.hasNext() {o=i.next(); /* do something with o */ } that's unlikely.
The only real improvement would come from reduced typechecking needed due to the use of generic Lists and Iterators (and even that is limited because those too are expanded).


42
Ian Darwin
author
Ranch Hand

Joined: Aug 03, 2001
Posts: 64
wondering the Data Structuring with Generics, foreach, and Enumerations , would it improve significant performance result ? say for "foreach" , will this feature perform better and faster as compare ordinary "for" loop

These features will make developers perform better, by typing less and getting more reliable code.

They won't do very much for runtime performance; if this is an issue you can now buy 2- and 4-CPU AMD Opteron systems.

Ian


Ian Darwin
Many questions are answered in my Java Cookbook, 2nd Edition
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Java Cookbook : Performance question
 
Similar Threads
[Ant]Iterate over Tokens
How to use array of beans in jsp
JSTL and Results
JSTL's EL. Problem iterating over arraylist
loops in ant script