home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SGTOOL10.ARC / PRINTCMP.C < prev    next >
C/C++ Source or Header  |  1993-07-19  |  2KB  |  71 lines

  1. /*
  2. SG C Tools 1.0
  3.  
  4. (C) 1993 Steve Goldsmith
  5. All Rights Reserved
  6.  
  7. Example comparing speed of string output with puts() and printstrvdc().  It
  8. takes puts() 9.07 secs to output string to VDC.  printstrvdc() only takes
  9. 1.07 secs!  That's 9 times faster than puts()!  printf() will be even slower
  10. than puts() for string output.
  11.  
  12. Compiled with HI-TECH C 3.09 (CP/M-80).
  13.  
  14. To compile with HI-TECH C and SG C Tools source on same disk use:
  15. C PRINTCMP.C VDC.OBJ
  16. */
  17.  
  18. #include <hitech.h>
  19. #include <conio.h>
  20. #include <vdc.h>
  21.  
  22. #define appClrScrCh 32
  23.  
  24. void putstest(void);
  25. void printstrtest(void);
  26.  
  27. char appTestStr[] = {
  28. "This is a string used to test the output speed of puts() vs printstrvdc()"
  29. };
  30.  
  31. main()
  32. {
  33.   savevdc();                        /* save vdc regs and set global vars */
  34.   clrscrvdc(appClrScrCh);           /* clear screen */
  35.   clrattrvdc(vdcAltChrSet);         /* clear attributes */
  36.   setcursorvdc(0,0,vdcCurNone);     /* turn cursor off */
  37.   outvdc(vdcFgBgColor,vdcDarkBlue); /* set new screen color */
  38.   printstrvdc(0,0,vdcAltChrSet,
  39.   "Compare puts() to faster printstrvdc().  Press [RETURN] to start.");
  40.   while (getch() != 0x0D);          /* wait for return press */
  41.   putstest();
  42.   printstrtest();
  43.   restorevdc();                     /* restore registers saved by savevdc() */
  44.   clrscrvdc(appClrScrCh);
  45.   clrattrvdc(vdcAltChrSet+vdcWhite);
  46. }
  47.  
  48. void putstest(void)
  49. {
  50.   uchar I;
  51.  
  52.   putchar(0x1A); /* clear-home cursor */
  53.   for (I = 1; I <= 23; I++)
  54.     puts(appTestStr);
  55.     printstrvdc(0,24,vdcAltChrSet+vdcBlink,
  56.     "String output using puts().  Press [RETURN].");
  57.   while (getch() != 0x0D);          /* wait for return press */
  58. }
  59.  
  60. void printstrtest(void)
  61. {
  62.   uchar I;
  63.  
  64.   putchar(0x1A); /* clear-home cursor */
  65.   for (I = 0; I <= 22; I++)
  66.     printstrvdc(0,I,vdcAltChrSet,appTestStr);
  67.     printstrvdc(0,24,vdcAltChrSet+vdcBlink,
  68.     "String output using printstrvdc().  Press [RETURN].");
  69.   while (getch() != 0x0D);          /* wait for return press */
  70. }
  71.