modified test routine to get average running time

to get the average running time for N trials