Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: fast speed app run WinBatch yield wbt IntControl(43, p1, 0, 0, 0) optimization exclusive
The trick is to find the slow spots (DebugTrace can help) and optimize those. Someplace for each line of the DebugTrace file is a number in parenthesis. This number is a timestamp (milliseconds?) of what time the statement was executed.
With some poking around you can figure out where the big time delays are.
Basic rule of thumb 90% of the time is spent in 10% of the code. Optimize that 10% and don't worry about trying to squeeze time out of the rest.
Hints that I would not like to let people know about....
WinBatch, compiler or not, is kind of an obscure hybrid of an Interpreter and a compiler, being somewhat closer to an interpreter.
Most of the time is spend figuring out what the statements are telling it to do. Very little time is actually spent doing the intended task. Tests have shown that, in general, nothing affects executing time so much as simply the number of lines of code. Grabbing the next line and figuring out what is is telling WinBatch to do takes all the time. It seems to not matter quite so much how much stuff is on the line.
Therefore...
xx=0
where xx is the index for a for loop can help.
On consecutive logons (after logging off and not restarting or rebooting the computer), the WB EXE would always run at "normal" speed, regardless of which version of WBDBV34I.DLL was in the C:\WINDOWS directory. This was not a problem for us with the "B" version of the WBDBV32I.DLL (to which we have now restored to all such computers that use this system), only the "C" version. This leads us to believe that there is a significant problem with the "C" version of the WBDBV32I.DLL.
In general, by default Winbatch now gives much more processing time to whatever other applications are running. So, for example, if a screensaver is running, it can monopolize the processor and Winbatch will wait around for it to give back some processing time.
Try adding Exclusive(@on) to the top of your script, and see if that fixes it. This will make Winbatch alot stingier in terms of processor time. Then, if there are parts of your script where you don't want Winbatch to take so much, you can turn Exclusive(@off).
This indicates a severe configuration problem on the machine.
What version of Windows are you running? Are you using the 16 or 32 bit version of WinBatch.
The answer is likely to revolve around priority settings for the forground application. If it is set too high, it swipes all possible time away from the WinBatch script that is NOT running in forground or from the poor application trying to start up.
IntControl(43, p1, 0, 0, 0) (32-bit only)and the Enable/disable "WaitForInputIdle" to change the idle setting.
Granted this pushes the limits of string handling a bit, and granted WinBatch is an interpreted language, etc. But it's still _very_ slow to process. Is there any way to tell Win95 to speed up WinBatch, give it extra timeslices, or something like that???
You might try this trick. At the top of the script set each word as a variable (except WinBatch reserved works like "end" "next" "for" "while" and assorted function names. Then it quick to check words.
osterich=1 feather=1 furry=1 handcuff=1 baseball=1 ;Open file here while 1 ;read line for each word on line if IsDefined(word) then ... ; the word is in our list. ; avoiding search loop next endwhileAlso the Binary Operations are about 10 faster than the File Operations. You could read the file in in one swell foop, and then parse thru the binary buffer. If you are just interested in word counts, a flurry of BinaryStrCnt functions would provide that.
Instead of reading a line at a time and doing string manipulation to extract a word, you can change it around to read the file into a binary buffer and pull words out using BinaryIndex, (using the spaces between words as a delimiter and skipping ahead in the buffer the length of each word you find).
Article ID: W13170
Filename: Make WinBatch Faster.txt
File Created: 2003:02:12:13:35:18
Last Updated: 2003:02:12:13:35:18