Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!csd4.csd.uwm.edu!jgreco From: jgreco@csd4.csd.uwm.edu (Joe Greco) Newsgroups: comp.sys.cbm Subject: Re: Super-C: Why so slow??? Keywords: printf() is slower than BASIC! Message-ID: <1332@uwm.edu> Date: 4 Dec 89 22:50:58 GMT References: <46@ka2qhd.UUCP> Sender: news@uwm.edu Reply-To: jgreco@csd4.csd.uwm.edu (Joe Greco) Organization: Interstellar Telephone, Telegraph, and Telepath, Inc. Lines: 33 In comp.sys.cbm article <46@ka2qhd.UUCP>, kd2bd@ka2qhd.UUCP (John Magliacane) wrote: >I recently wrote a real-time earth satellite tracking program using this >compiler, and was pleased with the results, except with the fact that the >printf() function is WAY TOO SLOW! BASIC is much faster with screen I/O. > >I was wondering if anyone else has noticed this, and if so, if they were able >to "speed things up a bit". The real advantage of compiling is having >fast executable code, and Super-C does this, except for screen I/O. If you know anything about C, you'll realize that printf is a standard library function. Now, I have had nearly no experience with C on the Commodore (but years of Commodore experience) but I'll give you some advice I learned when learning C on our Unisys supermini here at UWM.... printf is an extremely flexible routine. It can handle almost all of your output needs. However, this means that it is also extremely complex and fairly long, code-wise. If you don't need all of the formatting and output conversions, use putc, puts, or putw. These routines operate a heck of a lot nearer to machine-level and will greatly increase speed. printf itself was originally written in C, and I believe it itself called these routines. Most modern C compilers have this and other library routines written in assembler for maximized speed, but it is possible that Super-C does not. In summary, try using lower level I/O routines. Save printf for those tasks for which it would be too difficult to write your own routine. By the way, if you can avoid printf entirely (without too much hassle), do so. It takes up lots of memory. -- jgreco@csd4.csd.uwm.edu Joe Greco at FidoNet 1:154/200 USnail: 9905 W Montana Ave PunterNet Node 30 or 31 West Allis, WI 53227-3329 "These aren't anybody's opinions." Voice: 414/321-6184 Data: 414/321-9287 (Happy Hacker's BBS)