1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <time.h> 5 #include <sys/time.h> 6 #include <sys/resource.h> 7 #include "fec.h" 8 9 int main(){ 10 unsigned char block[255]; 11 int i; 12 void *rs; 13 struct rusage start,finish; 14 double extime; 15 int trials = 10000; 16 17 for(i=0;i<223;i++) 18 block[i] = 0x01; 19 20 rs = init_rs_char(8,0x187,112,11,32,0); 21 encode_rs_char(rs,block,&block[223]); 22 23 getrusage(RUSAGE_SELF,&start); 24 for(i=0;i<trials;i++){ 25 #if 0 26 block[0] ^= 0xff; /* Introduce an error */ 27 block[2] ^= 0xff; /* Introduce an error */ 28 #endif 29 decode_rs_char(rs,block,NULL,0); 30 } 31 getrusage(RUSAGE_SELF,&finish); 32 extime = finish.ru_utime.tv_sec - start.ru_utime.tv_sec + 1e-6*(finish.ru_utime.tv_usec - start.ru_utime.tv_usec); 33 34 printf("Execution time for %d Reed-Solomon blocks using general decoder: %.2f sec\n",trials,extime); 35 printf("decoder speed: %g bits/s\n",trials*223*8/extime); 36 37 38 encode_rs_8(block,&block[223],0); 39 getrusage(RUSAGE_SELF,&start); 40 for(i=0;i<trials;i++){ 41 #if 0 42 block[0] ^= 0xff; /* Introduce an error */ 43 block[2] ^= 0xff; /* Introduce an error */ 44 #endif 45 decode_rs_8(block,NULL,0,0); 46 } 47 getrusage(RUSAGE_SELF,&finish); 48 extime = finish.ru_utime.tv_sec - start.ru_utime.tv_sec + 1e-6*(finish.ru_utime.tv_usec - start.ru_utime.tv_usec); 49 printf("Execution time for %d Reed-Solomon blocks using CCSDS decoder: %.2f sec\n",trials,extime); 50 printf("decoder speed: %g bits/s\n",trials*223*8/extime); 51 52 exit(0); 53 } 54 55