I am looking for a tool to make the profiling of a TypeScript Node.js application, and this without modifying the whole code source.
I mean by profiling: launching the application using some specific tool, which outputs the result like this:
Method | consumed memory | consumed time
a() | 1024 | 20ms ….
I did some internet research and I have found this one: https://github.com/screepers/screeps-typescript-profiler
But using it, I'm obliged to edit the whole code (by adding the @Profiler decorator), I'm looking for something to detect the methods automatically.
Thanks for your help!
You can use WebStorm IDE for V8 CPU and Memory Profiling. Here is a guide: https://www.jetbrains.com/help/webstorm/v8-cpu-and-memory-profiling.html.
There is no need to change any part of your code. You can run V8 Profiling, take Heap Snapshots and view useful snapshot diffs.
You can use the default Webstorm guide, however, for Node 12 there is a bug and you will get an error in CLI: bad option: --log-timer-events
.
For Typescript project with Express and Socket.io server, I use it with ts-node-dev tool which simply passes all unknown params to ts-node
and then to node
. So, you can apply the same approach when using ts-node
. Set --prof
and --logfile=logfile-profiling.log
arguments manually. Here is my example configuration:
Disable Record CPU profiling info to avoid the bug (we set --prof and --logfile manually) and enable Allow taking heap snapshots.
Then run Debug for this configuration. To take a new heap snapshot click to a bottom icon of a left side panel while debugging your app:
Heap Snapshots and CPU profiling logs will be stored in your project folder and you can analyze them from menu Tools > V8 Profiling > Analyze V8 Heap Snapshot as well as for CPU logs: Analyze V8 Profiling logs. CPU profiling logs are created in intervals, so you can run your app and open new logs at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With