Skip to content

Commit 6d4f349

Browse files
authored
Fix import of multithreaded Chrome profiles (#194)
In #160, I wrote code which incorrectly assumed that at most one profile would be active at a time. It turns out this assumption is incorrect because of webworkers! This PR introduces a fix which correctly separates samples taken on the main thread from samples taken on worker threads, and allows viewing both in speedscope. Fixes #171
1 parent ad49dac commit 6d4f349

File tree

7 files changed

+3565
-15
lines changed

7 files changed

+3565
-15
lines changed

sample/profiles/Chrome/70/worker.json

Lines changed: 2613 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<script>
2+
function banana() {
3+
let prod = 1
4+
for (let i = 1; i < 1000; i++) {
5+
prod *= i
6+
}
7+
return prod
8+
}
9+
10+
function apple() {
11+
for (let i = 0; i < 1000; i++) {
12+
banana()
13+
}
14+
}
15+
16+
let bounces = 0
17+
18+
const worker = new Worker('./worker.js')
19+
20+
worker.onmessage = function() {
21+
apple()
22+
if (bounces++ < 10) {
23+
worker.postMessage('ping')
24+
}
25+
}
26+
27+
worker.postMessage('ping')
28+
</script>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function gamma() {
2+
let prod = 1
3+
for (let i = 1; i < 1000; i++) {
4+
prod *= i
5+
}
6+
return prod
7+
}
8+
9+
function alpha() {
10+
for (let i = 0; i < 1000; i++) {
11+
gamma()
12+
}
13+
}
14+
15+
onmessage = function(e) {
16+
alpha()
17+
postMessage('pong')
18+
}

0 commit comments

Comments
 (0)