Results 1 to 3 of 3

Thread: (ASP) nested FOR loops, which way is more efficiant

  1. #1

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057

    (ASP) nested FOR loops, which way is more efficiant

    which is better (both are large), this:
    Code:
    For x= 1 To 2
      For y=1 To 30
        blah
      Next
    Next
    or this
    Code:
    For y=1 to 30
      For x=1 to 2
        blah
      Next
    Next
    they both do the process 60 times but is one way better than the other?
    thanks
    michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    They should be the same. You could try benchmarking to find out, but the program isn't having to do anything different, and you aren't stacking anything or consuming extra memory.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

  3. #3

    Thread Starter
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    OK, I figured that was the case. I was just thinking that 2 for loops for 30 was better than 30 for loops for 2
    thanks
    michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width