Solved

Increasing load time of algorithm

Posted on 2004-10-01
2
197 Views
Last Modified: 2010-05-02
My program is taking way too long to load, and I wanted to see if you experts knew of a better solution to my problem.
I have a program that takes in data dynamically. Sometimes it can load fast if the data it needs to read is small, but other times it needs to read and manipulate lots of data, and that is when it is taking forever. The function I use manipulate_data runs fast, it's processing all the queries and going through all the for loops that is taking so long. Is there another alternative? For example, would pushing the data on a stack run faster?

** I can have an infinite number of groups with each group having an infinite number of items in that group. **
**This is not the actual code. Just an example of what i'm doing**

1) Read in the amount of groups SQL query to database using RDO
2) Determine the amount of items in that group:
3) Manipulate all the data items in each group, then move on to the next group

For each GroupItem in the GroupCollection
   call manipulate_data
next

Sub manipulate_data()

For Each dataItem In colItems
     
         Sql = "SELECT * DataItemValues
         
         Set rsData = rdoConnect.OpenResultset(Sql, adOpenDynamic, adLockPessimistic)
     
         Do Until rsData.EOF
     
               DataItem.ManipulateData
               DoEvents
               Sleep 100

               'Update db with current state
               Select Case DataAction
                  Case 1
                     strSql = "Update Data1 set State = 1
                  Case 2
                     strSql = "Update Data2 set State = 2
                  Case 3
                     strSql = "Update Data3 set State = 3
               End Select

               rdoScriptConnect.Execute Sql
         
           
            rsData.Update
            rsData.MoveNext
       
      Loop
     
        rsData.Close
   
Next

End Sub


**By the way, I'm goint to be out of town this weekend. I'll check this again on monday**
Thanks in advance
0
Comment
Question by:LeeHenry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 250 total points
ID: 12204222
Three questions.

1.  Have you done any testing to see which part of the code is causing the slowdown?
2.  What does DataItem.ManipulateData do?
3.  Why the Sleep 100?
0
 
LVL 3

Accepted Solution

by:
redfordb earned 250 total points
ID: 12205007
1) At first glance, the sleep shouldnt be there.
2)Instead of using the DO UNTIL LOOP do the following...

   Add two new variables ie NumOfRecords and RecordLoop

   After your open set NumofRecords to the records in the dataset ie
   'Open dataset
   NumOfRecords = rsData.recordcount
   RecordLoop = 0
   While Not (RecordLoop > NumOfRecords)
        'Put your processing here...
         RecordLoop = RecordLoop + 1
   Wend
  'Continue with your code

3) Before and after each stage in your loop add a write to an output file (like a log). Then run the program and analyze the log for delays.
4) If the long delays are justified, look at putting in a progress bar or something so the user knows something is happening. It makes the wait more bearable.

   
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question