c - Execution time in Miracl library -


in bmark program, execution time calculated follow:

for example, ec point multiplication:

#define min_time 10.0 #define min_iters 20  start=clock(); { ecurve_mult(); iterations++; elapsed=(clock()-start)/(double)clocks_per_sec; } while (elapsed<min_time || iterations<min_iters); elapsed=1000.0*elapsed/iterations; printf("er - %8d iterations",iterations); printf(" %8.2lf ms per iteration\n",elapsed); 

the question is: why not use:

start=clock(); ecurve_mult(); elapsed=(clock()-start)/(double)clocks_per_sec; printf("%f\n",elapsed*1000.0); 

in other words, purpose of using min_time , min_iters

nb: 2 codes give different outputs.

the code trying execute ecurv_mult() enough times make lack of precision in time measurement. loop makes sure gets executed @ least 20 times , @ least 10 seconds.

since machines might fast executing 20 times not enough time accurate precision, on make sure @ least 10 seconds regardless of how fast did 20 times.

if once, our performance measurement not going accurate due resolution of clock being high (e.g. clock gives 1ms while benchmark runs in 500us).


Comments