-
Notifications
You must be signed in to change notification settings - Fork 2
/
sample_rate.html
103 lines (98 loc) · 1.92 KB
/
sample_rate.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<html>
<!-- Investigates when the profiler takes a sample.
We know the profiler samples every ~1ms, but is it the same time? Random times? Drifting times?
-->
<body>
<script>
var x = ['done'];
var p = window.performance;
var f = Math.floor;
function tenth1() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0 && r < 0.1);
}
function tenth2() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.1 && r < 0.2);
}
function tenth3() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.2 && r < 0.3);
}
function tenth4() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.3 && r < 0.4);
}
function tenth5() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.4 && r < 0.5);
}
function tenth6() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.5 && r < 0.6);
}
function tenth7() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.6 && r < 0.7);
}
function tenth8() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.7 && r < 0.8);
}
function tenth9() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.8 && r < 0.9);
}
function tenth10() {
do {
var s = p.now();
var r = s - f(s);
} while (r >=0.9 && r < 1.0);
}
function run100() {
var s = p.now();
var d = 0;
while (d < 100) {
tenth1();
tenth2();
tenth3();
tenth4();
tenth5();
tenth6();
tenth7();
tenth8();
tenth9();
tenth10();
d = p.now() - s;
}
}
// Delay this startup be 1s to make sure that the browser is in
// a stable state.
window.setTimeout(function() {
run100();
run100();
run100();
run100();
document.body.innerHTML = "Done:" + x.join('-');
}, 1000);
</script>
</body>
</html>