home *** CD-ROM | disk | FTP | other *** search
- /*
- SG C Tools 1.0
-
- (C) 1993 Steve Goldsmith
- All Rights Reserved
-
- Example comparing speed of string output with puts() and printstrvdc(). It
- takes puts() 9.07 secs to output string to VDC. printstrvdc() only takes
- 1.07 secs! That's 9 times faster than puts()! printf() will be even slower
- than puts() for string output.
-
- Compiled with HI-TECH C 3.09 (CP/M-80).
-
- To compile with HI-TECH C and SG C Tools source on same disk use:
- C PRINTCMP.C VDC.OBJ
- */
-
- #include <hitech.h>
- #include <conio.h>
- #include <vdc.h>
-
- #define appClrScrCh 32
-
- void putstest(void);
- void printstrtest(void);
-
- char appTestStr[] = {
- "This is a string used to test the output speed of puts() vs printstrvdc()"
- };
-
- main()
- {
- savevdc(); /* save vdc regs and set global vars */
- clrscrvdc(appClrScrCh); /* clear screen */
- clrattrvdc(vdcAltChrSet); /* clear attributes */
- setcursorvdc(0,0,vdcCurNone); /* turn cursor off */
- outvdc(vdcFgBgColor,vdcDarkBlue); /* set new screen color */
- printstrvdc(0,0,vdcAltChrSet,
- "Compare puts() to faster printstrvdc(). Press [RETURN] to start.");
- while (getch() != 0x0D); /* wait for return press */
- putstest();
- printstrtest();
- restorevdc(); /* restore registers saved by savevdc() */
- clrscrvdc(appClrScrCh);
- clrattrvdc(vdcAltChrSet+vdcWhite);
- }
-
- void putstest(void)
- {
- uchar I;
-
- putchar(0x1A); /* clear-home cursor */
- for (I = 1; I <= 23; I++)
- puts(appTestStr);
- printstrvdc(0,24,vdcAltChrSet+vdcBlink,
- "String output using puts(). Press [RETURN].");
- while (getch() != 0x0D); /* wait for return press */
- }
-
- void printstrtest(void)
- {
- uchar I;
-
- putchar(0x1A); /* clear-home cursor */
- for (I = 0; I <= 22; I++)
- printstrvdc(0,I,vdcAltChrSet,appTestStr);
- printstrvdc(0,24,vdcAltChrSet+vdcBlink,
- "String output using printstrvdc(). Press [RETURN].");
- while (getch() != 0x0D); /* wait for return press */
- }
-