>The small program below, uses the scientific functions of sin and cos. It >draws a circle of any number of given points entered by the user and plots >them out on the screen. > >This was my first draft of the program in FB and it uses input and a very >ungraceful way to exit the program. However, this is the version that I >used to time the program at work on other machines so this is the version >that is here. > >Timing the program for a 100 point circle: > >6100/60 3 min 8 sec <- my machine >LC-550 2 min 26 sec >7600/120 1 min 55 sec >Quadra-650 57 sec <- the winner > >The Challenge: >I would like to see (or know) how fast this program will run compiled as a >cpuFAT. Running native on a Power Mac, it should then beat the pants off of >the Quadra-650. Right? Larry, It took 1 min 30 sec on my Power Computing Power Center 150. This program would probably be sluggish even in native Power PC code. It calls the trig functions 40000 times to draw a 100 point circle. I changed your example to remove these trig function calls from the main loop. This version only takes 4 seconds to draw 100 points. In general I have always been able to keep from having to call trig functions or doing floating point math in a loop by building a lookup table like the one used in the example below. If you want your program to be speedy only use integer math in loops. A file translation program that originally used floating point math in the main loop took about 4 hours to process a typical file. When I removed all the floating point math from the main loop a typical file processed in less than 1 min. -Joe Lertola '---------- CUT HERE ----------- WINDOW 1,"Spirograph",(0,0)-(500,400) "start" PI! = 6.283185307 PRINT % (30,383) "TO EXIT PROGRAM, YOU MUST CLICK MOUSE WHILE DRAWING A CIRCLE" PRINT % (260,21);:PRINT "HIT RETURN TO DRAW CIRCLE" PRINT % (2,21); INPUT "NUMBER OF POINTS IN THE CIRCLE: ";N PRINT % (260,21);:CLS LINE PRINT % (260,21) "POINTS COMPLETE:" PRINT % (2,33) "CLICK MOUSE TO EXIT PROGRAM" IF N=0 THEN CLEAR:CLS:BEEP:GOTO "start" DIM xArray(100),yArray(100),count1,count2 count1=0 FOR X! = 0 TO PI! STEP PI! / N xArray(count1) = INT (SIN (X!) * 150) + 249 yArray(count1) = INT (COS (X!) * 149) + 200 INC(count1) NEXT X! count1=0 : H = 0 FOR X! = 0 TO PI! STEP PI! / N x1=xArray(count1) : y1=yArray(count1) count2=0 FOR Z! = 0 TO PI! STEP PI! / N x2=xArray(count2) : y2=yArray(count2) PLOT x1,y1 TO x2,y2 IF FN BUTTON STOP INC(count2) NEXT Z! PRINT % (373,21);:CLS LINE H=H+1:PRINT % (375,21) H INC(count1) NEXT X! PRINT % (2,33);:CLS LINE PRINT "CLICK MOUSE TO CLEAR SCREEN" DO UNTIL FN BUTTON OR LEN(INKEY$) CLEAR:CLS:GOTO "start"