-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
36 lines (36 loc) · 1000 Bytes
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<head>
<meta charset="utf-8"/>
</head>
<script type="text/javascript">
/**
* Takes in amount of trials to run in a given time and retur$
*
* @param trials
* @param time
* @return time of attempts
*/
function getTimes(trials,time){
var trialArray = [];
for (var i=0;i < trials;i++){
trialArray[i] = 0;
}
console.log(`Running ${trials} trials each for ${time$
setTimeout(recursive_perf_calculator,time,time,perfor$
setTimeout(array_printer, trials*time + 1000 ,trialAr$
}
function recursive_perf_calculator(wait, t0, time_array,index$
if (index > 0 ) {
time_array[index] = performance.now() - t0;
console.log("Iteration took: ",time_array[index]);
setTimeout(recursive_perf_calculator, wait,wait, perfor$
}
}
function array_printer(array) {
var sum = 0;
for (var i = 0 ;i < array.length; i++){
sum += array[i];
}
console.log("average runtime: " , sum/array.length);
}
getTimes(10,450);
</script>