This project was originally developed independently and has been used in projects at Fabrique and Q42. It remains publicly available and can be forked or maintained independently if needed. No guarantees are provided for long-term maintenance.
Simple profiler for Node. Get a CPU Profile, Heap Profile or Heap Snapshot that can then be loaded into VSCode or Chrome DevTools.
Init the profiler with the desired type.
Optionally, a filename prefix can be added (default is __) as the second argument.
import Profiler from '@eklingen/node-profiler'
const profiler = new Profiler('cpu') // Can be `cpu` (default), `heap` or `heap-snapshot`Then start profiling.
profiler.start()
When enough data has been gathered, stop profiling. The results will be written to disk with the current timestamp and given prefix as filename. The filename will be returned.
const filename = profiler.stop() // Example: "__20240429121317474.cpuprofile"
None.
Copyright (c) 2024 Elco Klingen. MIT License.