inspector-slim
v2.0.0
Published
A simple node module to access V8 inspector + some tools to export and read the data.
Downloads
9
Maintainers
Readme
inspector-slim
A lightweight fork of inspector-api with zero dependencies. All AWS/S3 functionality has been removed — this package only uses Node.js built-ins.
Purpose
Simple wrapper around "inspector" module. Basically it adds promises & async/await syntax.
Compatibility
| Version | Supported | Tested | |:-------------:|:-------------:|:--------------:| | 20.x | yes | yes | | 18.x | yes | yes | | 16.x | yes | yes |
Requires Node.js 14 or higher.
Installation
$ npm install inspector-slim --saveUsage
CPU profiling
const Inspector = require('inspector-slim')
const inspector = new Inspector()
await inspector.profiler.enable()
await inspector.profiler.start()
// Invoke business logic under measurement here...
// some time later...
await inspector.profiler.stop()Memory sampling
const Inspector = require('inspector-slim')
const inspector = new Inspector()
await inspector.heap.enable()
await inspector.heap.startSampling()
// Invoke business logic under measurement here...
// some time later...
await inspector.heap.stopSampling()Memory snapshot
const Inspector = require('inspector-slim')
const inspector = new Inspector()
await inspector.heap.takeSnapshot()Code coverage
const Inspector = require('inspector-slim')
const inspector = new Inspector()
await inspector.profiler.enable()
await inspector.profiler.startPreciseCoverage({ callCount: true, detailed: true })
const data = await inspector.profiler.takePreciseCoverage()
await inspector.profiler.stopPreciseCoverage()Write to disk
const Inspector = require('inspector-slim')
const inspector = new Inspector({
storage: {
type: 'fs'
}
})
await inspector.profiler.enable()
await inspector.profiler.start()
// Invoke business logic under measurement here...
// some time later...
await inspector.profiler.stop()Files are written to your system's default tmp directory. You can find it with require('os').tmpdir().
Constructor config
new Inspector([config])config.storage
| Option | Description | Default |
|:-------:|:----------------------------------------:|:-------:|
| type | Storage type (raw or fs) | raw |
Test
$ npm testCoverage report can be found in coverage/.
