Do'h! Yeah, using the name 'ints' probably wasn't a good choice here. Looks like I should re-read Item 56: Adhere to generally accepted naming conventions. :)
On Thu, Jun 4, 2009 at 1:09 PM, Alex Rudnick <[email protected]> wrote: > > Yeesh, pardon. That's an ArrayList called "ints" of Integers, not > containing ints. I retract that statement! > > On Thu, Jun 4, 2009 at 4:04 PM, Alex Rudnick <[email protected]> wrote: >> Sounds like boxing/unboxing overhead, in that case! >> >> What if you tried that with an array of native ints? >> >> On Thu, Jun 4, 2009 at 3:47 PM, Aaron Steele <[email protected]> wrote: >>> >>> So item 46 in Effective Java says that there shouldn't be a >>> performance penalty using the nice for loops. But the following test >>> in Eclipse on my machine (MacBook Pro, Intel Core Duo, 2.16 GHz) shows >>> a performance penalty. >>> >>> Given an ArrayList called ints with 1 million Integers, this takes 31 >>> milliseconds: >>> for (int i = 0, size = ints.size(); i < size; i++) >>> ints.get(i).intValue(); >>> >>> And this takes 76 milliseconds: >>> for (Integer i : ints) >>> i.intValue(); >>> >>> What am I missing? Probably just some super naive testing on my part. :) > > -- > Alex Rudnick > swe, gwt, atl > > > > -- Sent from Piedmont, CA, United States --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
