[comp.sys.mac.programmer] Think Pascal 3.0 and Set constants

aberno@questor.wimsey.bc.ca (Anthony Berno) (03/24/91)

Hello. I have been writing data acquisition software for a Mac IIcx/fx using 
Think's Lightspeed Pascal. I've been away from my work since last summer 
(being a student) and in my absence, a coworker of mine has been diddling 
with the code I wrote.

The program in question is collecting data from AMS experiments at rates of 
500-10000 cps. One day, the aforementioned coworker discovered that the 
machine was starting to bog down at rates of over 1000 per second - most of 
the work done is around 2-800, but sometimes goes up to 7000. After much 
searching and heartache, the cause was found.

He had upgraded to Think Pascal version 3 (I was using version 2), and it 
seems that one single line in the code was bogging things down. It was:

if WhichHist in [1,2,3,4] then
        ChannelChanged 1D^^[TheData^^[index,WhichHist]] := true
else
        ChannelChanged1D^^[TotalE] := true;

The problem lay in the use of set constants, which seem to be handled 
differently under 3.0. The above line was called once for every event, so it 
had a large effect.

I estimate that this single if statement takes about a HUNDRED times longer 
under 3.0! Now, it has been removed and replaced with something more elegant 
- no flames please, I know it was a dumb idea in the first place. And no, I 
can't set the "set of integer" flag to 0..255 because I use a set elsewhere 
that is larger (that will also be removed!) It's just very much worth noting 
that this seems to perform very differently under 3.0.

This is all slightly second hand, as I am about 1000 miles away from where 
this was all discovered... but I figured that someone out there might like 
to know about it.

If you have anything to say on this matter, please email me as I can only 
post to this group, not read it.


 ---
    Anthony Berno (aberno@questor.wimsey.bc.ca)
      The QUESTOR Project: Free Public Access to Usenet & Internet in
                            Vancouver, BC, Canada, at +1 604 681 0670.