bench.js
function stat(fn, n) {
	var n2 = n,
		times = [],
		sum = 0,
		t, avg, median
	while (n2--) {
		t = fn()
		sum += t
		times.push(t)
	}
	avg = sum / n
	times.sort(function (a, b) {
		return a - b
	})
	median = times[Math.floor(times.length / 2)]
	if (times.length % 2 === 0) {
		median = (median + times[times.length / 2 - 1]) / 2
	}
	return {
		avg: avg,
		median: median
	}
}
function stat(fn, n) {
	var n2 = n,
		times = [],
		sum = 0,
		t, avg, median
	while (n2--) {
		t = fn()
		sum += t
		times.push(t)
	}
	avg = sum / n
	times.sort(function (a, b) {
		return a - b
	})
	median = times[Math.floor(times.length / 2)]
	if (times.length % 2 === 0) {
		median = (median + times[times.length / 2 - 1]) / 2
	}
	return {
		avg: avg,
		median: median
	}
}
function stat ( fn , n ) { var n2 = n , times = [ ] , sum = 0 , t , avg , median while ( n2 -- ) { t = fn ( ) sum += t times . push ( t ) } avg = sum / n times . sort ( function ( a , b ) { return a - b } ) median = times [ Math . floor ( times . length / 2 ) ] if ( times . length % 2 === 0 ) { median = ( median + times [ times . length / 2 - 1 ] ) / 2 } return { avg : avg , median : median } }
Make a statistical experiment on fn
@param {Function} fn A function that receives nothing and returns a number
@param {number} n Number of probes to takes
@returns {{avg: number, median: number}}
Make a statistical experiment on fn