1 /* 2 * $id: rgb_timing.c 142 2005-03-11 02:56:31Z rgb $ 3 * 4 * See copyright in copyright.h and the accompanying file COPYING 5 */ 6 7 /* 8 *======================================================================== 9 * This is not a standard test -- this just times the rng. It therefore 10 * has a very nonstandard initialization and return. One can still create 11 * the test, but the **test struct is used only to determine the number 12 * of samples used in the timing test. 13 *======================================================================== 14 */ 15 16 #include <dieharder/libdieharder.h> 17 rgb_timing(Test ** test,Rgb_Timing * timing)18int rgb_timing(Test **test, Rgb_Timing *timing) 19 { 20 21 double total_time,avg_time; 22 int i,j; 23 unsigned int *rand_uint; 24 25 MYDEBUG(D_RGB_TIMING){ 26 printf("# Entering rgb_timing(): ps = %u ts = %u\n",test[0]->psamples,test[0]->tsamples); 27 } 28 29 seed = random_seed(); 30 gsl_rng_set(rng,seed); 31 32 rand_uint = (uint *)malloc((size_t)test[0]->tsamples*sizeof(uint)); 33 34 total_time = 0.0; 35 for(i=0;i<test[0]->psamples;i++){ 36 start_timing(); 37 for(j=0;j<test[0]->tsamples;j++){ 38 rand_uint[j] = gsl_rng_get(rng); 39 } 40 stop_timing(); 41 total_time += delta_timing(); 42 } 43 avg_time = total_time/(test[0]->psamples*test[0]->tsamples); 44 45 timing->avg_time_nsec = avg_time*1.0e+9; 46 timing->rands_per_sec = 1.0/avg_time; 47 48 free(rand_uint); 49 50 return(0); 51 52 } 53 54