Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

efficient programing???

Options
  • 18-06-2002 3:19pm
    #1
    Registered Users Posts: 15,258 ✭✭✭✭


    could anyone out there give me some tips on making my program more efficient.

    i am designing an application for a pocket pc. up until last week everything was running at a pretty good pace. i have to perform a search on a database and then display the info on screen. everything was going great. no slow down at all. was only taking about 1-2 secs.

    now i have to compare my result against another DB and display that info on screen also. it takes maybe 5-10 secs.
    i think this is way too slow. there must be a faster way.

    the info that is displayed on screen is all graphical. but there is never any more than 20 of these icons on screen at once, all 15*15 pixels. the placement of these icons was always fast until i added the second DB compare.

    is there any specific rules out there to make your program run more smoothly.

    i would put up with this little problem if i could display a progress bar. at least then i could see my program working away instead of looking at a blank screen. but i cant find any info in creating a progress bar in eVB. i think it can be done in VB.

    thanks


Comments

  • Registered Users Posts: 4,156 ✭✭✭Quigs Snr


    I think there is a 3rd party add-in for progress/status bars for VB CE. Have a look round.

    Your compares will always be slow when there are two seperate databases. You might be able to speed it up, by opening connections to both on application startup. This leads to very messy programming if you're not carefull and leaves you open to memory leaks etc... unless you're careful. Just a thought.


  • Registered Users Posts: 15,258 ✭✭✭✭Rabies


    You might be able to speed it up, by opening connections to both on application startup. This leads to very messy programming if you're not carefull and leaves you open to memory leaks etc... unless you're careful. Just a thought.

    ya the prob started once the second DB was introduced. what ever result i get in one DB i might have to compare it against the other. but both DBs are not always used at the same time. it all depends on how you use the application. different button presses mean that you could only be using one of the DBs or both of them.

    i would rather not open the connection at start up because it is not a sure thing that both will be used. it all depends on the user. if it leads to memory leaks or messy programming then i definitly dont want to do it.

    i'll take a look around for the 3rd party progress/status bar.
    thanks.


  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    If you explain (or post code for) the comparison routine, it would be helpful in trying to spot problems.

    Incidentally - what type of DBs are we talking about? SQL 2000 CE edition, or something else?

    jc


  • Registered Users Posts: 2,781 ✭✭✭amen


    1: Are u using precompiled SPs are just passing sql to the database ?
    precompile SP will be quicker

    2: Are the dbs on the same database machine ? If so and u can tell u need to do a compare when pressing the command button u should be able to write a query to do the compare on the db and return your results. Generally much quicker

    3:20 icons seems like a lot of controls

    e


  • Registered Users Posts: 15,258 ✭✭✭✭Rabies


    sorry i should have made myself clearer. wasnt thinking what i was typing. there is two tables in my DB (not two DBs) on the pocket pc. the DB is of type *.cdb (pocket access). using ADOCE if thats any help

    one table is always used. this displays icons on the screen. the table has over 5000 records.

    when the correct records are found they are displaed on screen graphicaly. only about 20 are ever on screen at once. dimensions:15*15 pixels

    if the user decides to select different option then different data is also displayed on screen. but are only ever about 5 or 6 of these icons on screen at any one time. dimensions:10*10 pixels

    these are displayed relative to the first results.

    hmm... dont think i'm making much sense...

    sitting back and thinking about maybe the reason is the images are slowing things up a bit. the icons are no more than 1.7kb in size. maybe that is the prob and not my code.....
    the redrawing of everything is probably taking longer because i have introduced a second table.

    i'll have to sit down and think out my strategy more tomorrow.

    thanks anyway


  • Advertisement
  • Registered Users Posts: 15,443 ✭✭✭✭bonkey


    The first thing to do is identify where the problem is.

    Even something as simple as four message boxes can show you this :

    0) Preparing stuff
    1) Calling to DB
    2) Back from DB
    3) Resultset processed.

    If the problem is between 0 and 1, then you're doing something braindead in deciding how to process things (i.e 1 table or 2). If the slowdown is between steps 1 and 2, then its your query, or your tables (indexes perhaps). If its between steps 2 and 3, then youre doing something daft with your result-processing code.

    In theory, the processing of the resultset should be pretty much identical for the 1-table or 2-table situation....so its either your prep or your query.

    Of course...it is also possible that you have made a complete booboo and run the 1-table query always, and then discard it and run the 2-table query if needed....if you see what I mean.

    Basically - track down the bottleneck. Messageboxes are a great way of doing this....simple and very effective.

    jc


  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    Simple way is...

    Create a timer and have it write to a data file it's location and how much time has passed.

    Stick it between all areas you believe are major (eg. drawing screen start, stop. Db access start, stop). From there you can find what's causing the over head. Then just add further timer markers within the offending code.


  • Registered Users Posts: 15,258 ✭✭✭✭Rabies


    thanks hobbes
    thanks bonkey

    i'll try both our your ideas....


  • Closed Accounts Posts: 423 ✭✭Dizz


    If your using VisualStudio of some flavour you might want to check out the profiling options in there - much better than interleaving timer calls in your code and keeps things cleaner. Also if your app ain't multi-threaded, I'd suggest going that way too along with the suggested DB optimisations of above. You might want to re-think your DB schema too.

    Dizz


Advertisement