Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ![]() Interested in joining? Click here. If you are already a member of ZBCode, feel free to login right here: |
- Pages:
- 1
- 2
| Coding For Loops | |
|---|---|
| Tweet Topic Started: Aug 15 2008, 07:24 AM (909 Views) | |
| Ryura | Aug 21 2008, 07:35 PM Post #11 |
![]()
|
That's actually the slowest method you can do. for (var in obj) should only be used for objects - it actually has to check keys/vals while using the arr.length property is much quicker, especially when cached. |
![]() |
|
| Zoopey | Aug 22 2008, 10:44 AM Post #12 |
|
Can anyone else hear the music?
![]()
|
I think it's admirable people are thinking about their codes' execution times, but I feel that the current problem inhibitions our society computer-wise is not everyone's average processor speed but everyone's average internet connection; thus what probably should be focused on is load times, not execution times. That's why I worry more about the shortest way to code something rather than the way to make it run fastest. I have been told my prorities are screwed up though, especially after I started wondering whether or not I had left my goldfish enough food when my parents were looking for their lost boarding cards and passports in a foreign country. *wonders* |
| ♬ Come sail away, come sail away, come sail away with me! ♬-Styx[ustyle][prefix=][suffix=][/ustyle] | |
![]() |
|
| Ryura | Aug 22 2008, 08:19 PM Post #13 |
![]()
|
With the small size of most JS files and caching, as well as faster internet connections, load speed is no longer too much of an issue. Believe me, when you're trying to make an event that loops through 1000's of DOM - or even object - elements, good looping matters. Users with slow connections expect pages to load slow, but they do *not* expect slow response when clicking on elements of a page. |
![]() |
|
| Zoopey | Aug 23 2008, 08:55 AM Post #14 |
|
Can anyone else hear the music?
![]()
|
Duly noted.
|
| ♬ Come sail away, come sail away, come sail away with me! ♬-Styx[ustyle][prefix=][suffix=][/ustyle] | |
![]() |
|
| Eureka DC | Sep 21 2008, 08:04 PM Post #15 |
![]()
|
Though it's necessary at times, like an extend method for an Object.
That is still not the fastest way because you're making the code iterate the array to get the length before you do your cycle. It should go through the array in one cycle. Same for all the do-while loops displayed here. But in truth, they are faster than the one Webworldx started with in the original post of this topic.
Edited by Eureka DC, Sep 21 2008, 08:06 PM.
|
DO NOT PM ME FOR HELP, SUPPORT OR REQUESTS!![]() ------------------------------------------------------------------- I'm a part of you, you're a part of me And I know it's wrong but I can't get free You're like my first bad habit How am I gonna give you up? ~ Vanessa Hudgens ------------------------------------------------------------------- | |
![]() |
|
| Reid | Apr 18 2009, 07:13 PM Post #16 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
I feel this topic needs bumping, regardless of how old it is. I just did a little research and the results are astounding when you have your length cached. The timing doesn't matter until you start adding code upon code. For example, zbcode, even though it's heavily modified, takes very little time to load, whereas I've been to some boards that take 5-6 seconds just to begin executing code thanks to all of the inefficient scripts inhabiting the place.. And, remember, some browsers ( like IE... ouch ) take a super long time just to execute code. In a single script it doesn't matter too much, but once you have 2-3 or 5-6 scripts sitting around it does really slow things down. Also.. while a lot of the coders here do this, for any future ones - restrict codes to specific pages. For example, you shouldn't bother the user with a script that modifies how you send PMs on pages that only have topics. I've been bad in the past about optimization but looking through a VERY detailed benchmark study lately, I just felt that this needed a bump...
|
| The Resource Board | |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Code University · Next Topic » |
- Pages:
- 1
- 2

















7:48 PM Jul 10