test: add test profiling script#7086
Conversation
commander.jsCo-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
SirzBenjie
left a comment
There was a problem hiding this comment.
It's worth noting that this is of limited usefulness due to our mocks. Most of our memory / performance bottlenecks are going to be due to the canvas and UI processing. That is effectively disabled here. We can optimize the 10%, but the other 90% is probably UI. Regardless, LGTM.
|
@SirzBenjie I'm more interested in why we got a sudden 50% spike in test duration. |
|
So this doesn't allow passing arguments to Vitest, and it doesn't itself pass Also, I'm getting |
|
Please elaborate. You need to make the vitest args the last ones passed to the function. |
|
What are the changes the user will see?
N/A
Why am I making these changes?
Makes it much easier to debug memory and performance bottlenecks in code.
What are the changes from a developer perspective?
Added a new script,
pnpm test:profile, that instruments a Vitest test run, processes the generated profiler logs, and writes the results to disk to be viewed in a flamegraph tool.I took the liberty of adding
commander.jsand its type-checked cousin as a dev dependency (which we really should be using, given how much it streamlines the wholeprocess.argvpipeline)Note
Given VS Code natively supports opening
.cpuprofileand.memprofilefiles as a flamegraph, I saw it unnecessary to use an external tool to visualize them. (Also because I couldn't get it to work correctly.)Screenshots/Videos
How to test the changes?
Run
pnpm test:profile, then open the results in your flamegraph tool of choice. (VSCode has an extension for this, for what it's worth.)Checklist
betaas my base branchbeta,mainor the name of another long-lived feature branchpnpm test:silentto test locally)pnpm test:create) or updated existing tests related to the PR's changes if necessary