Mail Archives: djgpp/1994/11/23/09:21:08
As a possible cause for a program being slow for GCC and fast for BC++
D.J. Delorie (DJ) said among others than
DJ>Also, kbhit() might be more expensive than you think.
I got very interesting results when I recompiled one of my old programs ( a substitute for 'strings').
First I tried all versions of TC/TCC/BCC and found that the program speed was very slow.
Newer Borland compilers generated bigger and (somewhat) slower code than the older one. The size
increase was from 12 kbytes (TC 1.5) to 39.9 kbytes (BCC++ 4.0), the speed decrease only marginal.
Newertheless it took 2 min. 10 sec to seek through a 1.3 mbytes file. The program uses kbhit()/
getchar() pairs to let the user stop or interrupt the processing. Using GCC and kbhit()/keybin() pair the same file was scanned in 7.8 seconds ! If I took out the kbhit()/getchar() combination from
the source then BCC 4.0 gave me 10.3 seconds (486 DX2 66Mhz).
The memory usage of the program is about 1 kbytes, and it reads the file using getc().
So it seems that 1) kbhit() does not slow the program down too much under GCC, but slowes down
BCC tremendously. 2) disk IO using getc() cannot be much slower with GCC than with BCC.
Andras
- Raw text -