In investigating a suspected network latency problem, I got sidetracked and noticed something interesting. If I put an OSOPEN statement in a loop, the %Processor Time shown in the System Monitor drops to near zero. I tried experimenting with a few statements and came up with the following short list:
0% OSOPEN
0% OSCLOSE
12% XLATE
60% FLUSH
100% INPUT X,-1
~2% A loop that does an INPUT X,-1 whenever TIME() changes.
98% A loop that does an INPUT X,-1 whenever DOSTIME() changes.
50-60% A loop that does an INPUT X,-1 whenever DOSTIME() changes by more than 0.1.
Can anyone explain the disparity, and particularly why input x,-1 is so expensive compared to others? Can anything useful be made of these findings? Note that I'm NOT using yield.
To simplify (purely because that's the level of my understanding
) the Input,-1 tells Windows that the application is polling the keyboard ergo is it concerned with user interaction ergo it should be given priority. There is more to it than this but that's a rough synopsis. Hence the success of CpuPlus at reducing cpu utilisation which works amongst other things by slowing down the rate of keyboard polling.
The Sprezzatura Group
World Leaders in all things RevSoft
Victor,
Let me buy you a drink someday and tell you about the 75,000 lines of assembler involved in working out why it is as it is.
The entire story makes for enthralling reading.
If you're on life support.
Steve