Super Bottleneck Breaker
Contest winner improves powerful BASIC speed-up tool
By Eric Woodruff
The April 1989 issue of Antic ran a program called Bottleneck Breaker by Stan Lackey. This BASIC profiler measured how much time a running BASIC program spent executing any particular line or group of lines Once identified, the most heavily used lines could then be streamlined to speed up the program's performance.
Antic challenged readers to relocate the profiler's counters to the 130XE's alternate memory bank, allowing the profiler to work with larger programs. The winning entry, Super Bottleneck Breaker, not only uses the extra memory of an XE, but features additional modifications that make the original more user friendly. This BASIC program works on 8-bit Atari computers with at least 48K memory and disk drive
I have made the modifications to Bottleneck Breaker so that the counters are now located in the 130XE's extra memory.
In addition, I modified the profiler to make use of all the 130XE's extended memory and now there is a counter for each line of a BASIC program from 0 through 31767 inclusive. I have also made changes that allow the profiler's interrupt routine to be placed anywhere in memory with a few changes to the loader.
By default, Super Bottleneck Breaker is loaded into Page 6 starting at memory location 1536. By modifying the value of the variable START in line 100, the profiler can be placed at a different memory location. If you prefer to reserve memory for it, you can place a REM on line 100 and remove the REM from line 80.
I moved the profiler on/off flag to memory location 1278 ($04FE hex). This allows for the program's mobility. One other thing, Super Bottleneck Breaker will now detect if the program is running or not, using the on/off flag set to on if the program is running (POKE 1278, non-zero value). If the BASIC program is not running, the profiler will turn the flag off for you and stop profiling.
Super Bottleneck Breaker's analysis routine has also been modified to take advantage of the extended memory. You can now produce a report to the screen or printer for a specified number of bottlenecks (1-255).
The same cautions given in the original article still apply. The program you are profiling cannot use lines 1-3 or 31765-31766, or you won't be able to add the program lines which control the profiler. If the profiler tries to sample your program while the BASIC interpreter is moving from one line to the next, a garbage line number will appear in the final report. This happens rarely enough that it does not affect the results in any significant way.
One exception to the original cautions is that the only memory locations the Profiler now uses are 208 and 209 ($D0, $D1 hex). Still, if your program uses these locations, the profiler may produce wrong answers or crash.
Type in Listing 1, PROFILE1.BAS, check it with TYPO II and SAVE a copy to disk.
Next, type NEW, then type in Listing 2, PROFILE2.LST, check it with TYPO II and LIST a copy to disk. If you have trouble typing the special characters in line 2, don't type them in. Instead, type in Listing 4 and check it with TYPO II. When you RUN Listing 4, it creates this hard-to-type line and stores it in a file called LINES.LST. (Make sure you don't already have a file by that name on your disk before you RUN Listing 4.)
To merge the two programs, type NEW, then ENTER "D:PROFILE2.LST" and then ENTER "D:LINES.LST". Be sure to LIST the completed program to disk.
Now, type NEW, then type in Listing 3, PROFILE3.BAS, check it with TYPO II and SAVE a copy to disk.
In addition to the programs needed to run the profiler, Antic Disk owners will find three MAC65 files on disk containing source code for the profiler (PROFILE.M65) and for the assembler routines that the profiler uses (MEMCLR.M65, CNTANL.M65). These files are included for the reference of MAC/65 programmers and are not needed to run the profiler.
USING THE PROFILER
The procedure for running the Profiler is still the same as the original:
1. RUN "D:PROFILE1.BAS" to load the Profiler into memory.
2. LOAD the program to be profiled.
3. Check that the program does not contain lines numbered 1, 2, 3, 31765, or 31766.
4. ENTER "D:PROFILE2.LST"
5. RUN your program.
6. RUN "D:PROFILE3.BAS"
When you run PROFILE3.BAS, the screen will blank and there is a slight delay while the analysis routine is loaded into memory. You are then asked how many bottlenecks you want to see. Enter a number from 1 to 255. The program then asks if you are sure. If the wrong number was entered, just type an [N] and press [RETURN]. A new value can then be entered.
Next, the program informs you that the screen will blank during analysis and gives an estimated time (minutes:seconds) for the analysis. The time will vary from a few seconds for a small number of bottlenecks, up to about 8 minutes 6 seconds for 255 bottlenecks. To begin the analysis, just press [START].
When the analysis is complete, the screen will reappear and the total counts will be accumulated. A prompt will then appear asking if the report wil be sent to the screen or printer. Just enter an [S] or a [P] depending on your preference. A report is then prepared showing the line number, number of counts, percentage of total counts taken up by the line, and a cumulative percentage. A
Eric Woodruff lives in Medical Lake, Washington. This is his first Antic appearance.
Listing PROFILE1.BAS Download
Listing PROFILE2.LST Download / View
Listing PROFILE3.BAS Download
Listing MEMCLR.M65 Download / View
Listing PROFILE.M65 Download / View
Listing CNTANL.M65 Download / View