Re: VB slows down

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Andrew Faust (afaust_at_aradymeDOTcom)
Date: 07/13/04


Date: Tue, 13 Jul 2004 10:23:32 -0600


"Noelia" <Noelia@discussions.microsoft.com> wrote in message
news:902BA97C-E349-455E-9347-7F87F09F4F06@microsoft.com...
>
> Can you suggest another way of writing to file?
dim f as integer

f = freefile
open "c:\FilePath\FileName.txt" for output as #f
print #f, "Data"
close #f

> I still think the problem is the loops though.

Probably not unless this is running on a very slow computer. You
said in your first post that it should end
up with about 96,000 iterations. For modern computers this isn't
really all that large. I consistantly need to
work with loops in excess of 100,000 iterations, and don't find
any speed issues due to the loop. You can test
this by removing all the code from within the body of your loops
and seeing how fast they execute. It shouldn't be
more than a minute.

> In the beginning it processes and writes to file very fast.

This is because as files get larger and larger, it takes windows
more time to allocate more space for the file as the file
grows. One thing that I have needed to do in the past is to
estimate how large a file will be required, then to create
a file that large right to start with. You can then populate the
file as needed and truncate it down to size when you are
done (or grow it in larger chunks as needed.) I would try
replacing the FSO first, before trying drastic measures like
this, though.

Andrew Faust



Relevant Pages

  • Re: VBA end if without block if and loop without do errors on code
    ... therefor I had to use nested loops to get enough iterations. ... Dim i As Byte, j As Byte, k As Byte ... second Sub with Data type Integer ...
    (microsoft.public.vb.general.discussion)
  • Re: Seen java -server optimization vary 50%?
    ... >> I time and print this every hundred iterations. ... >> kill it and start it over the time can be substantially ... >whose most frequently executed loops do a lot of accesses to ... >for an explanation of some important indexing approaches. ...
    (comp.lang.java.help)
  • Re: List of random numbers
    ... Loops 198643 ... I wrote a benchmark to run the code 10 times for 100000 number lists, ... Iterations for last number 24797 ...
    (comp.lang.rexx)
  • Re: List of random numbers
    ... Swifty wrote: ... Loops 198643 ... Iterations for last number 24797 ... I presume you've done all the tricks to eliminate as much overhead as possible? ...
    (comp.lang.rexx)
  • Re: VBA end if without block if and loop without do errors on code
    ... therefor I had to use nested loops to get enough iterations. ... Dim i As Byte, j As Byte, k As Byte ... second Sub with Data type Integer ...
    (microsoft.public.vb.general.discussion)