c - Code benchmarking statistics - -
as wrote in previous topic: benchmarking code - doing right? need find way benchmark statistics, average, mean, standard deviation, etc. how can using methods posted? notice use solution benchmark code time interval, not calling function many times. ideas?
i came one, dont know if correct (pseudocode):
buffsize = 1024; buffer [buffsize]; totalcycles = 0 // arrays walltimeresults = [] cputimeresults = [] // benchmarking in (0, iterations): start = walltime(); fun2measure(args, buffer); end = walltime(); walltimeresults[i] = end - start; start = cputime(); fun2measure(args, buffer); end = cputime(); cputimeresults[i] = end - start; c1 = cyclecount(); fun2measure(args, buffer); c2 = cyclecount(); cyclesperbyte = c2-c1/(buffsize); totalcycles += cyclesperbyte; in range (0, iterations) : sum += walltimeresults[i]; avg_wall_time = sum / iterations; sum = 0; in range (0, iterations) : sum += cputimeresults[i]; avg_cpu_time = sum / iterations; avg_cycles = totalcycles / iterations;
is correct? how mean, standard deviation, etc?
your average looks ok.
mean (i.e. average) is
mean = 1/n * sum( x[i] )
standard deviation square root of variance:
sigma = sqrt( 1/n * sum( (x[i]-mean)^2 )
Comments
Post a Comment