如何使用 node CLI 命令分析 Nest.js 应用程序?

How to profile a Nest.js application by using node CLI command?

我一直在为 REST API 服务器开发 Nest.js 应用程序,我想使用 Node.js 分析工具进行一些性能分析。 我知道有几种工具,如 WebStorm V8 CPU 和内存分析 (https://www.jetbrains.com/help/webstorm/v8-cpu-and-memory-profiling.html#node_profiling_before_you_start) 和节点 CLI 选项 --prof.

但是,我不知道如何使用 node CLI 程序启动我的 Nest.js 应用程序,所以我不知道如何将这些分析工具应用到我的 Nest.js申请。

有什么方法可以对 Nest.js 应用程序使用 Node.js 分析工具吗?或者Nest.js申请还有其他好的解决方案吗?

提前致谢。

您可以使用 nest build 构建应用程序,然后使用 node --prof dist/main 运行 构建应用程序。或者你可以只使用 nest start --watch -e 'node --prof' 这应该告诉 Nest 使用 node --prof dist/main 作为启动命令