X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd588,75064a58c47bba35 X-Google-Attributes: gidfd588,public X-Google-ArrivalTime: 1994-02-28 21:29:35 PST Newsgroups: alt.ascii-art.animation Path: gmd.de!xlink.net!howland.reston.ans.net!usenet.ins.cwru.edu!nigel.msen.com!well!barrnet.net!sgiblab!sgigate.sgi.com!odin!training!lindes From: lindes@training.asd.sgi.com (David Lindes) Subject: Re: Slow down the animation Message-ID: Sender: news@odin.corp.sgi.com (Net News) Nntp-Posting-Host: training.asd.sgi.com Organization: Silicon Graphics, Inc. Mountain View, CA References: <1994Feb17.143411.28909@ll.mit.edu> Date: Tue, 1 Mar 1994 05:29:35 GMT Lines: 78 In <1994Feb17.143411.28909@ll.mit.edu>, loden@ll.mit.edu (Tom R. Loden *8^0) writes: > Well, on a Sun SPARC II, it didn't seem to slow things down > at all. But using usleep() was TOO slow. I found inserting > a dummy loop did just fine. ( it did slow it down on mine... but on other points:...) problem with dummy loops is they're much less processor efficient. also, you CAN change the argument to usleep()... the argument is in microseconds (and will be some arbitrary amount more than what you specify, depending on system load, overhead for the call, etc.). (what i did was to add something like this in the code:... /* delay between charachters, in microseconds */ #define DELAY 1000 ...and change the "1000" argument to usleep() to "DELAY") unfortunately, on the system i'm currently on, i don't have usleep, or it's in a library other than what i'm compiling with, or something, but there are a few other things that i would suggest to make the program more efficient (which you'll then slow back down, to make it be just as you want it) first, you might want to get rid of the fflush(), and optionally replace it with a call to put you in cbreak mode. (not sure off hand how to do this on most platforms when you're not acting on stdin as your stream... though i suppose you could close stdin and re-open it as the other file, and then just call cbreak() ;-) also, change your primary loop do something more like this: while ( (c=getc(stream))!=EOF ) { delay (); putc (c, stdout); } fclose (stream); (the old version, which i'd have to post this to go back to, at the moment, was SOMETHING like: while( feof(stream) != EOF ) { int c=getc(stream); if(c==EOF) { fclose(stream); return; } fflush(stream); putc(c,stdout); } ... much more overhead, more calls, etc., slowing the program down tremendously.) there may be other things you can do too, but i'm not thinking of much more, at the moment... cheers. david lindes lindes@asd.sgi.com P.S. PLEASE NOTE: the intent of this message is not to cut down anyone's code!!! the intent is to provide some suggestions that may help more people have a more versitile "scat" program. i hope it helps. P.P.S. #include