[Sunhelp] C++ compiler options

James Lockwood james at foonly.com
Tue Mar 14 01:26:44 CST 2000


On Mon, 13 Mar 2000 mjohnson at forsythemca.com wrote:

> I have not used the SUN Visual Workshop for C++ or a C++ compiler lately.  I
> have a development group asking me what switches and options to use to optimize
> performance.  I hope you can help.
> 
> Secondly, the same development group has written the following code reading a
> text file that has 128 characters per record (numerical data) as attached.  The
> puzzling thing is that it runs in 0.19s when the system calls and screen output
> are commented out, and it runs in 1min 12s with system calls and screen output
> in.  I am not as familiar with the code since I have not written any for quite
> some time.  Again, I hope you can help.

No offense, but I think this development group is in sore need of some
education.

system() is terribly inefficient.  It forks the process, execs a shell,
hands it the command line you pass, and then sits around until the whole
mess completes.  It's handy to have for putting together a quick hack, but
it's almost never what you want to use in finished code. 

Calling tput from a program is also generally a bad idea.  You should be
using curses to handle smart terminal output.  You can avoid the overhead
of constantly synchronizing the virtual and real terminal buffers if you
only call refresh() once every second or so.

There also appear to be an interesting mix of C and C++ design elements,
but I doubt these are adversely affecting performance.

-James







More information about the SunHELP mailing list