DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Module speed issues

  1. #1
    Join Date
    Jan 2007

    Module speed issues

    Hi, I've been learning how to use the bit blt and associated API functions recently for some simple game programming and have finally hit a stumbling block that I can't seem to find any information on.

    Originally, I had all my graphics related code (such as getting DCs, etc) in the Form_Load part of my program. After this getting really messy to edit, I decided to start using a module to separate out graphics related commands. All I did was copy and paste blocks of code from various parts into the module and only changed a few references (such as when I needed information about the size of something on the form and so on). Now, a process which used to take ~350 ms now takes ~2500 ms. I've gone through step by step and it's following the exact same logical process that it was before, but, for some reason, is taking a whole lot longer. Unfortunately, I have no clue why this is.

    The variables I use within the module are declared as private for the entire module, as are the api functions. I removed all similar declarations from the form, so there isn't any sort of conflict there. There aren't any unnecessary calls, so that's not it.

    If anyone can help explain this quirkiness, I'd certainly appreciate it. I'd hate to have to go back to being sloppy again.

  2. #2
    Join Date
    Oct 2005
    maybe in debug mode only ,not at real run-time ??
    or maybe u have separeted portions of the code and put them in functions , so calling functions take much time than run them inline .. but if u have totally separeted complete functions maybe it's debug time problem only .

  3. #3
    Join Date
    Aug 2004
    Orange, California
    One thing to note is that you don't have to put the functions in a seperate module. You can keep them in the forms module. Just because you broke the code up into functions does not mean that those functions have to be in a seperate module.
    Next I have never heard of there being a speed difference between being in a module or in a forms module. As a test copy all of the code from the module to the bottom of the code in your forms module. Don't change anything just paste the code after the last line in the forms module, then remove the seperate module from the project and give it a run. Check to see if there is a time difference. I think you will find that there is no difference from being in a seperate module and being in the forms module. If I am correct then it has to do with the changes you made when you seperated the code into a seperate module. Start there and then report back what you find. At which point we can help you track down the slower code.

  4. #4
    Join Date
    Oct 2005
    Ron makes me remember one thing that in the form module functions should be "private" but in external module they must be public ... to be able to call them .. this is maybe which make the difference in time , to avoid this if your module has a function like "initGraphics" for example , and the rest of functions depend on this only so u may make this function only as public to call it from form module , and the rest of functions in the first module should be private as u don't need them externaly .
    this may decrease your weasted time and if u care about the rest of this time u may make as Ron told u to put them all in the same form module by private method .
    otherwise in most cases the class method make more efficient code -not after one test- but after long time of using your program .. and u should have it work well and fast .

Similar Threads

  1. how to use a common module
    By AM003295 in forum VB Classic
    Replies: 2
    Last Post: 12-29-2006, 06:20 PM
  2. Replies: 0
    Last Post: 12-23-2006, 10:28 PM
  3. Replies: 18
    Last Post: 12-13-2006, 03:49 PM
  4. HTML Control & Code Behind Module!
    By hari in forum ASP.NET
    Replies: 2
    Last Post: 04-02-2002, 04:21 PM
  5. Speed issues connecting to a database.
    By Andrea in forum VB Classic
    Replies: 1
    Last Post: 02-07-2001, 02:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center