-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(es/minifier): Add a script for samply profiler (#9923)
**Description:** I can copy-paste this script to merge needless stack trace items.
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
|
||
(async () => { | ||
const treeView = document.querySelector(".treeViewBodyInner.treeViewBodyInner1"); | ||
|
||
function sleep(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
function triggerMouseEvent(node, eventType) { | ||
var clickEvent = new PointerEvent(eventType, { button: 0, bubbles: true, cancelable: true }); | ||
node.dispatchEvent(clickEvent); | ||
} | ||
|
||
async function sendKey(node, key, keyCode, code) { | ||
node.dispatchEvent(new KeyboardEvent("keydown", { | ||
key: key, | ||
keyCode: keyCode, | ||
code: code, | ||
which: keyCode, | ||
shiftKey: false, | ||
ctrlKey: false, | ||
metaKey: false, | ||
bubbles: true, | ||
cancelable: true, | ||
})); | ||
node.dispatchEvent(new KeyboardEvent("keyup", { | ||
key: key, | ||
keyCode: keyCode, | ||
code: code, | ||
which: keyCode, | ||
shiftKey: false, | ||
ctrlKey: false, | ||
metaKey: false, | ||
bubbles: true, | ||
cancelable: true, | ||
})); | ||
|
||
} | ||
|
||
async function handleRow(row) { | ||
const lib = row.querySelector('.lib'); | ||
const libText = lib.textContent.trim(); | ||
if (libText.endsWith("/swc_ecma_visit/src/generated.rs") || | ||
libText.endsWith("/swc_ecma_utils/src/parallel.rs") || | ||
libText.includes('/.rustup/') || | ||
libText.includes('chili-0.2.0/') || | ||
libText.includes('scoped-tls-1.0.1/') || | ||
libText.includes('indexmap-2.5.0/') || | ||
libText.includes('hashbrown-0.14.5/') || | ||
libText.includes('/rust/deps/') || | ||
libText.includes('/better_scoped_tls/') || | ||
libText.includes('/swc_parallel/')) { | ||
triggerMouseEvent(row, "mouseover"); | ||
triggerMouseEvent(row, "mousedown"); | ||
triggerMouseEvent(row, "mouseup"); | ||
triggerMouseEvent(row, "click"); | ||
await sleep(30); | ||
|
||
await sendKey(row, 'm', 77, 'KeyM'); | ||
await sleep(100); | ||
return true; | ||
} | ||
} | ||
|
||
|
||
while (true) { | ||
const rows = treeView.querySelectorAll('.treeViewRow'); | ||
console.log(`Checking ${rows.length} rows`); | ||
|
||
|
||
let didWork = false; | ||
for (const row of rows) { | ||
if (await handleRow(row)) { | ||
console.log("Worked"); | ||
didWork = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!didWork) { | ||
break; | ||
} | ||
} | ||
|
||
})(); |