-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): add --cpu-prof flag (#2046)
* feat(cli): add --cpu-prof flag * chore: dynamically import profiler * docs: add debugging guide
- Loading branch information
Showing
10 changed files
with
547 additions
and
136 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,10 @@ | ||
--- | ||
'@pandacss/node': patch | ||
'@pandacss/dev': patch | ||
--- | ||
|
||
Add a `--cpu-prof` flag to `panda`, `panda cssgen`, `panda codegen` and `panda debug` commands This is useful for | ||
debugging performance issues in `panda` itself. This will generate a `panda-{command}-{timestamp}.cpuprofile` file in | ||
the current working directory, which can be opened in tools like [Speedscope](https://www.speedscope.app/) | ||
|
||
This is mostly intended for maintainers or can be asked by maintainers to help debug issues. |
This file was deleted.
Oops, something went wrong.
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
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
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
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,33 @@ | ||
import { logger } from '@pandacss/logger' | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
export const startProfiling = async (cwd: string, prefix: string) => { | ||
const v8Profiler = (await import('v8-profiler-next')).default | ||
const date = new Date() | ||
const timestamp = date.toISOString().replace(/[-:.]/g, '') | ||
const title = `panda-${prefix}-${timestamp}` | ||
|
||
// set generateType 1 to generate new format for cpuprofile | ||
// to be compatible with cpuprofile parsing in vscode. | ||
v8Profiler.setGenerateType(1) | ||
v8Profiler.startProfiling(title, true) | ||
|
||
const stopProfiling = () => { | ||
const profile = v8Profiler.stopProfiling(title) | ||
profile.export(function (error, result) { | ||
if (error) { | ||
console.error(error) | ||
return | ||
} | ||
if (!result) return | ||
|
||
const outfile = path.join(cwd, `${title}.cpuprofile`) | ||
fs.writeFileSync(outfile, result) | ||
logger.info('cpu-prof', outfile) | ||
profile.delete() | ||
}) | ||
} | ||
|
||
return stopProfiling | ||
} |
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
Oops, something went wrong.
f255342
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
panda-studio – ./
panda-studio-git-main-chakra-ui.vercel.app
panda-app.vercel.app
panda-studio-chakra-ui.vercel.app
f255342
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
panda-docs – ./website
panda-docs-git-main-chakra-ui.vercel.app
panda-docs.vercel.app
panda-docs-chakra-ui.vercel.app
panda-css.com
f255342
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
panda-playground – ./playground
panda-playground.vercel.app
panda-playground-git-main-chakra-ui.vercel.app
panda-playground-chakra-ui.vercel.app
play.panda-css.com