home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
509.lha
/
DES
/
src
/
benchmark.c
next >
Wrap
C/C++ Source or Header
|
1991-05-06
|
2KB
|
93 lines
/* Just run DES in a loop consuming CPU time; good for benchmarking
* Phil Karn
*
Time routines added as afterthought --SRP */
#include <stdio.h>
main()
{
float seconds,seconds2;
long hours,minutes,hours2,minutes2,days,days2;
struct time {
long days;
long minutes;
long ticks;
};
struct time w = {0,0,0};
struct time w2 = {0,0,0};
char key[8],work[8];
long iter,count;
desinit(0);
printf("Enter key (hex): ");
get8(key);
printf("Setting key: "); put8(key); printf("\n");
setkey(key);
printf("Enter starting value (hex): ");
get8(work);
printf("Starting value: "); put8(work); printf("\n");
printf("Number of iterations: ");
scanf("%ld",&count);
DateStamp(&w);
for(iter = 0;iter < count; iter++)
endes(work);
DateStamp(&w2);
printf("\nDONE.\n\n");
days=(w.days);
seconds = (w.ticks) / 50.0;
hours = (w.minutes) / 60;
minutes= (w.minutes)-(hours * 60);
days2=(w2.days);
seconds2 = ((w2.ticks) / 50.0);
hours2 = (w2.minutes) / 60;
minutes2= (w2.minutes)-(hours2 * 60);
if(seconds > seconds2){
seconds2 += 60;
minutes2--;
}
if(minutes > minutes2){
minutes2 +=60;
hours2--;
}
if(hours > hours2){
hours2 +=24;
days2--;
}
printf("Elapsed Time:\n\t %ld day(s) %ld hour(s) %ld minute(s) %.2f seconds\n",(days2-days), (hours2-hours), (minutes2-minutes), (seconds2-seconds));
}
get8(cp)
char *cp;
{
int i,t;
for(i=0;i<8;i++){
scanf("%2x",&t);
*cp++ = t;
}
}
put8(cp)
char *cp;
{
int i;
for(i=0;i<8;i++){
printf("%2x ",*cp++ & 0xff);
}
}