3 #include <sys/resource.h>
7 int keep_going
, count
, alternate
, seconds
;
8 struct rusage prior
, now
;
17 main(int argc
, char *argv
[])
20 u_long msecs
, key1
[8], key2
[8];
23 if (argc
< 2 || sscanf(argv
[1], "%d", &seconds
) != 1)
26 if (argc
< 3 || sscanf(argv
[2], "%d", &alternate
) != 1)
29 printf ("Running crypt%s for %d seconds of vtime...\n",
30 alternate
? " with alternate keys" : "", seconds
);
32 bzero(&itv
, sizeof (itv
));
33 signal (SIGVTALRM
, finish
);
34 itv
.it_value
.tv_sec
= seconds
;
35 itv
.it_value
.tv_usec
= 0;
36 setitimer(ITIMER_VIRTUAL
, &itv
, NULL
);
39 if (getrusage(0, &prior
) < 0) {
46 strcpy(k1
, "fredfredfredfredfred");
47 strcpy(k2
, "joejoejoejoejoejoejo");
50 for (count
= 0; keep_going
; count
++)
52 #if defined(LONGCRYPT)
53 crypt((count
& 1) ? k1
: k2
, "_ara.X...");
55 crypt((count
& 1) ? k1
: k2
, "eek");
59 for (count
= 0; keep_going
; count
++)
61 #if defined(LONGCRYPT)
62 crypt(k1
, "_ara.X...");
68 if (getrusage(0, &now
) < 0) {
72 msecs
= (now
.ru_utime
.tv_sec
- prior
.ru_utime
.tv_sec
) * 1000
73 + (now
.ru_utime
.tv_usec
- prior
.ru_utime
.tv_usec
) / 1000;
74 printf ("\tDid %d crypt()s per second.\n", 1000 * count
/ msecs
);