In the case of NodeJS, which use the V8 Engine [0], you have access to the diagonistics API [1] that allows you profile your cpu or memory consumption.
There are some tools that make that easier (see [2] or [3]) but you often left to interpret the result yourself
[0]: https://v8.dev/
[1]: http://nodejs.org/dist/latest-v12.x/docs/api/inspector.html#...
[2]: https://github.com/davidmarkclements/0x
[3]: https://github.com/vmarchaud/openprofiling-node
PS: Disclamer i wrote one of tool i mentionned above [3]