home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / ufc / speeds.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-12  |  1.3 KB  |  84 lines

  1. /*
  2.  * This fcrypt/crypt speed testing program
  3.  * is derived from one floating around in
  4.  * the net. It's distributed along with
  5.  * UFC-crypt but is not.
  6.  *
  7.  * Michael Glad, email: glad@daimi.aau.dk
  8.  *
  9.  * @(#)speeds.c    1.5 01/23/92
  10.  */
  11.  
  12. #include <sys/time.h>
  13. #include <signal.h>
  14. #include <stdio.h>
  15.  
  16. static int cnt;
  17. #define ITIME    10        /* Number of seconds to run test. */
  18.  
  19. void
  20. Stop ()
  21. {
  22.     printf ("Did %f %s()s per second.\n",
  23.         ((float) cnt) / ((float) ITIME),
  24. #if defined(FCRYPT)
  25.         "fcrypt"
  26. #else
  27.         "crypt"
  28. #endif
  29.     );
  30.     exit (0);
  31. }
  32.  
  33. /*
  34.  * Silly rewrite of 'bzero'. I do so
  35.  * because some machines don't have
  36.  * bzero and some don't have memset.
  37.  */
  38.  
  39. static void clearmem(start, cnt)
  40.   char *start;
  41.   int cnt;
  42.   { while(cnt--)
  43.       *start++ = '\0';
  44.   }
  45.  
  46. main ()
  47. {
  48.     struct itimerval itv;
  49.  
  50.     clearmem (&itv, sizeof (itv));
  51.  
  52.     printf ("Running %s for %d seconds of virtual time ...\n",
  53. #ifdef FCRYPT
  54.     "UFC-crypt",
  55. #else
  56.     "crypt(libc)",
  57. #endif
  58.         ITIME);
  59.  
  60. #ifdef FCRYPT
  61.     init_des ();
  62. #endif
  63.  
  64.     signal (SIGVTALRM, Stop);
  65.     itv.it_value.tv_sec = ITIME;
  66.     itv.it_value.tv_usec = 0;
  67.     setitimer (ITIMER_VIRTUAL, &itv, NULL);
  68.  
  69.     for (cnt = 0;; cnt++)
  70.     {
  71. #ifdef FCRYPT
  72.     fcrypt ("fredfred", "eek");
  73. #else
  74.     crypt ("fredfred", "eek");
  75. #endif
  76.     }
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.