forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudio-context-creation.html
46 lines (39 loc) · 1.26 KB
/
audio-context-creation.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
<!DOCTYPE html>
<html>
<body>
<script src="../resources/runner.js"></script>
<script>
function runTest() {
let isDone = false;
PerfTestRunner.prepareToMeasureValuesAsync({ done: () => isDone = true, unit: 'ms' });
async function runIteration() {
let startTime = PerfTestRunner.now();
let audioContexts = [];
for (let i = 0; i < 100; ++i) {
let context = new AudioContext();
audioContexts.push(context);
await context.resume();
}
for (let context of audioContexts) {
await context.suspend();
}
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
if (!isDone) {
if (window.GCController)
window.GCController.collect();
setTimeout(runIteration, 0);
}
}
runIteration();
}
window.addEventListener('load', event => {
let button = document.body.appendChild(document.createElement('button'));
button.innerText = 'Start test';
button.addEventListener('click', () => {
button.disabled = true;
runTest();
});
})
</script>
</body>
</html>