OLD | NEW |
1 function runTests(testFunc, cleanupFunc, finalizeFunc) | 1 function runTests(testFunc, cleanupFunc, finalizeFunc) |
2 { | 2 { |
3 const minRuns = 15; | 3 const minRuns = 15; |
4 const maxRuns = 400; | 4 const maxRuns = 400; |
5 const targetConfidenceInterval = 0.04; | 5 const targetConfidenceInterval = 0.04; |
6 | 6 |
7 let currentRun = 0; | 7 let currentRun = 0; |
8 let results = []; | 8 let results = []; |
9 function runNextTest() | 9 function runNextTest() |
10 { | 10 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 setTimeout(runNextTest, 0); | 44 setTimeout(runNextTest, 0); |
45 } | 45 } |
46 | 46 |
47 function getConfidenceInterval(results) | 47 function getConfidenceInterval(results) |
48 { | 48 { |
49 let sum = 0; | 49 let sum = 0; |
50 let sqrsum = 0; | 50 let sqrsum = 0; |
51 | 51 |
52 for each (let result in results) | 52 for (let result of results) |
53 { | 53 { |
54 sum += result; | 54 sum += result; |
55 sqrsum += result * result; | 55 sqrsum += result * result; |
56 } | 56 } |
57 | 57 |
58 let avg = sum / results.length; | 58 let avg = sum / results.length; |
59 let stddev = Math.sqrt((sqrsum - 2 * sum * avg + avg * avg * results.length) /
results.length); | 59 let stddev = Math.sqrt((sqrsum - 2 * sum * avg + avg * avg * results.length) /
results.length); |
60 let confidence = 1.96 * stddev; // 95% confidence, assuming Gaussian distribut
ion | 60 let confidence = 1.96 * stddev; // 95% confidence, assuming Gaussian distribut
ion |
61 return [avg, stddev]; | 61 return [avg, stddev]; |
62 } | 62 } |
OLD | NEW |