Results 1 to 10 of 10

Thread: The Best GGD That Was Ever Made

Threaded View

  1. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: The Best GGD That Was Ever Made

    Quote Originally Posted by Ben321 View Post
    So int(a/b) is slower than a\b. But how does a\b compare to just a/b. ... I'm guessing that since 4\2 doesn't have to worry about decimal point handling and such stuff (it simply drops any part of the output isn't in the integer part of the number), that 4\2 might be faster. Please let me know. Thanks.
    \ is noticeably faster
    Quote Originally Posted by Ben321 View Post
    Also I think C does go faster for example in VB6, to set B = A and then increment A by 1, in VB6 you would use:
    Code:
    Dim A as Integer: Dim B as Integer
    B = A
    A = A +1
    This can NOT be further optimized
    Yes it can... change Integer to Long.

    However, for something that simple, optimisation is clearly rather pointless.
    These 2 lines of code takes the time need to run only 2 lines of code, but performs THREE LINES of code worth of actions.
    The number of lines of code is no indicator of optimisation, what matters is the number of CPU clock cycles.

    For example, "DoEvents" is a rather simple line of code, but can easily take 200 milliseconds or more, whereas your A and B example should take under 1.

    As a general guideline, well optimised code usually has more lines than the unoptimised equivalent (just not for ridiculously simple examples). Shorter code is not the same thing as faster code.

    As for your comments about C, in order to determine whether or not the A++ version is more optimised, you would need to look at the machine code that is generated... and a decent C compiler should produce exactly the same machine code for both methods you used, in which case the A++ version is not any more optimised at all, it is just fewer lines of code in the IDE.

    As a side note for you to think about, it is no secret that when VB6 compiles your code, it uses a slightly modified version of a decent C compiler. You don't have all the abilities of C inside a VB program, but you have most of them, and lots of extra useful bits.
    Last edited by si_the_geek; Aug 13th, 2012 at 12:40 PM.

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