` Printed Icetips Article

Icetips Article



Par2: Speeding file opening: Class mod
2002-02-22 -- James Harper
 
i've been aware for a while that the application i've written isn't as fast
as it should be, particularly on opening screens. when i have some spare
time (rarely) i put in little bits of code to profile areas of code try and
track down what is taking up the time, and previously i had tracked it down
to opening files within the abfile.clw module but nothing specific.

anyway, this morning when i was testing something else i noticed that this
statement in abfile.clw:
    IF SELF.File{PROP:Thread}
      ThisThread = THREAD()
    END
was taking in the order of 4 to 5 hundredths of a second. not much you might
say but it exists in the method SetThread in FileManager and get's called
for every attempted open. Again that might not seem like a big deal but if
every table in your database is related to on average three other tables,
and you have a lot of tables in the first place, then this routine can get
called up to a few hundred times, which amounted in my case to around a 4
second delay on opening a window.

as far as i can tell it is the SELF.File{PROP:Thread} that takes the bulk of
the time, not the reading of THREAD. imho this is a bug.

In order to work around this i figured that if I read the Prop:Thread on an
open and cached it, there would be only one read of prop:thread call per
file instead of many.

The changes i made were:

to abfile.inc:
inserted the line:
Threaded   BYTE
on line 83, right under CleanedUp

to abfile.clw
inserted the line:
    SELF.Threaded = SELF.File{PROP:Thread}
on line 689, right under the setting of SELF.FileNameValue.
changed SELF.File{PROP:Thread} to SELF.Threaded on line 1215

the results were that the opening time of most of the main browses (launched
from the main menu) dropped from 3-5 seconds (unacceptable) to just under 1
second. This was measured by watching the seconds tick by on a clock and
therefore not a very scientific measurement but it is quite obviously
faster!!!

i've measured reading prop:thread from the file itself and it seems to take
no time at all, so perhaps it is because we are reading it via a reference
variable... no time to research this any further though.

if the tables in my database were fewer and weren't so closely related it
might not be so significant but in my case it was well worth the exercise.

hope someone finds some benefit from this!



Printed December 3, 2024, 11:10 am
This article has been viewed/printed 35212 times.