[comp.sys.att] Fastest way to output to terminal

matt@iquery.UUCP (Matt Reedy) (09/02/88)

We have a very terminal-I/O intensive application and are attempting to 
optimize the output to the terminal. (We looked at curses but decided against
it because we needed more flexibility.)  What is the fastest way to get 
output to the terminal?  We have tried two methods:

	write ( 1, line, strlen(line) ); building and writing a line at a time
		and
	setvbuf (stdout, _IOFBF, buf, 4096 )	
	fputs (line,stdout)		using a very large buffer size

Neither of these seems to be as fast as curses.  Someone told me curses is
faster because it doesn't send very many 'locate cursor' ( tgoto (CM..) )
commands.  Is this true?  Any other ideas?

Thanks in advance.  

matt
-- 
Matthew Reedy                 UUCP: {harvard!adelie,gatech!petro}!iquery!matt
Programmed Intelligence Corp. "Lots of people without brains do alot of talking"
400 N Loop 1604 E, Suite 330  Scarecrow - "Wizard of Oz"
San Antonio, TX  78232        (512) 490 6684

les@chinet.UUCP (Leslie Mikesell) (09/04/88)

In article <136@iquery.UUCP> matt@iquery.UUCP (Matt Reedy) writes:
>We have a very terminal-I/O intensive application and are attempting to 
>optimize the output to the terminal. (We looked at curses but decided against
>it because we needed more flexibility.)  What is the fastest way to get 
>output to the terminal?  We have tried two methods:
....
>Neither of these seems to be as fast as curses.  Someone told me curses is
>faster because it doesn't send very many 'locate cursor' ( tgoto (CM..) )
>commands.  Is this true?  Any other ideas?

Curses is fast because it doesn't actually output everything you send.  It
keeps track of what is already on the screen and skips anything that is
already there.  It also performs calculations to optimize the output
depending on the functions available on the particular terminal.  You
can get an idea of what is happening if your terminal has a "monitor"
mode where it displays control sequences instead of obeying them.

Depending on what you intend to display, it may be easy or difficult to
do this in your own code (probably difficult).

Les Mikesell

mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) (09/04/88)

->We have a very terminal-I/O intensive application and are attempting to 
->optimize the output to the terminal. (We looked at curses but decided against
->it because we needed more flexibility.)  What is the fastest way to get 
->output to the terminal?  We have tried two methods:
- ....
->Neither of these seems to be as fast as curses.  Someone told me curses is
->faster because it doesn't send very many 'locate cursor' ( tgoto (CM..) )
->commands.  Is this true?  Any other ideas?
- 
- Curses is fast because it doesn't actually output everything you send.  It
- keeps track of what is already on the screen and skips anything that is
- already there.  It also performs calculations to optimize the output
- depending on the functions available on the particular terminal.  You
- can get an idea of what is happening if your terminal has a "monitor"
- mode where it displays control sequences instead of obeying them.

I can corroborate the last paragraph above:
I actually had to do something like this on VMS once (no curses!).  We
had a terminal-output bound program, so to speed things up, we buffered
up 1 screen-update worth of output before blasting the buffered-up data
to the terminal.  It included (I think) internally optimizing cursor
motion commands to minimize the number of bytes sent to the terminal.
It speeded up the application appreciably.

Mike Khaw
-- 
internet: mkhaw@teknowledge.arpa
uucp:	  {uunet|sun|ucbvax|decwrl|uw-beaver}!mkhaw%teknowledge.arpa
hardcopy: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303