Results 1 to 3 of 3
  1. #1
    bill shockley is offline Novice
    Windows 7 64bit Access 97
    Join Date
    Sep 2011
    Posts
    4

    incrementally slower routine -- vba

    Excel 2010 - vba/Access 97
    I have a vba routine that runs nice and quick at the start but then gets slower and slower
    as it loops. I am parsing downloaded documents from the internet. Each document is similar --
    only very minor changes in text from one doc to the next.



    For each document, the parser will consult a database of html tags about a thousand times. I use
    the command rs.seek to find a corresponding substitution for each html tag. It is this "seek" operation
    that is slowing down. I put the line

    T1 = TIMER

    before the "seek" command, and the line

    T2 = TIMER

    afterwards. Then I sum up the thousand time measurements for each document to find out
    how much time is spent by the cpu executing that one line of code. This is where it is spending
    most of its time, and the time spent on that line grows in parallel with total processing time.

    Here is a picture of time spent on the "seek" line of code for the first 30 documents that were
    parsed.http://www.frontiernet.net/~wily11/seekTime.GIF

    I'm really drawing a blank as to what sort of mechanism is involved in this slowdown. My only
    thought was bad management of variables, but I did what troubleshooting I could think of in that
    regard. Tried closing the recordset and database after each document and setting their variables to
    Nothing. That's about it. Closing the spreadsheet and reopening does not help. It will resume at its
    most recent speed. Closing Excel will reset it to optimal speed.

    Thanks for looking.
    Shockley

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Have you tested the procedure without the timer code? Maybe it is the timer that is causing the slowdown. Try just Debug.Print Now before and after the loop.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bill shockley is offline Novice
    Windows 7 64bit Access 97
    Join Date
    Sep 2011
    Posts
    4
    Quote Originally Posted by June7 View Post
    Have you tested the procedure without the timer code? Maybe it is the timer that is causing the slowdown. Try just Debug.Print Now before and after the loop.
    I was chasing a bad lead. I tried debugging by stripping out code step by step. It turned out the slowdown occurred without the seek command even in the program. I kept thinking it had to be a variable containing a mushrooming amount of text. And that's what it was. Each document that I parse is about 30K characters. One variable that I wasn't using anymore and therefore not paying attention to, but was nevertheless active, was receiving the entire text of the document every time there was a new document, and I neglected to zero that variable for each new document, so it was growing rapidly in size and, I presume, eating up memory. The program slowed down gradually and if left to run long enough, eventually generated an error and crashed. It was just a hunch of mine that the seek code was causing the problem, but the seek line was slowing only because everything was slowing because of the diminishing memory.

    Faith restored -- for now...

    Thanks for your ears. It really helps!

    Shockley

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Database slower under Windows 7
    By krzycho23 in forum Access
    Replies: 5
    Last Post: 04-27-2012, 01:07 AM
  2. Query filters slower, if left open
    By Frenotx in forum Queries
    Replies: 5
    Last Post: 01-25-2012, 03:25 PM
  3. Replies: 3
    Last Post: 02-09-2011, 07:43 AM
  4. Example Importing routine
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-24-2010, 12:35 AM
  5. having a field which incrementally serializes
    By Kevin in forum Programming
    Replies: 1
    Last Post: 03-04-2010, 12:30 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
  •  
Other Forums: Microsoft Office Forums