Socket
Socket
Sign inDemoInstall

inspector-api

Package Overview
Dependencies
163
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    inspector-api

A simple node module to access V8 inspector + some tools to export and read the data.


Version published
Weekly downloads
34K
decreased by-5.5%
Maintainers
1
Install size
7.85 MB
Created
Weekly downloads
 

Readme

Source

GitHub release GitHub license

CI pipeline Code coverage Opened issues Opened PR DeepScan grade Node version

Purpose

Simple wrapper around "inspector" module. Basically it adds :

  • promises & async/await syntax
  • S3 exporter

Compatibility

VersionSupportedTested
20.xyesyes
18.xyesyes
16.xyesyes

In order to have all features we recommend to use at least Node.js version 10 or higher.

Installation

$ npm install inspector-api --save

Usage

CPU profiling

const Inspector = require('inspector-api')
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-api')
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-api')
const inspector = new Inspector()

await inspector.heap.takeSnapshot()

Code coverage

const Inspector = require('inspector-api')
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()

Use S3 exporter

const Inspector = require('inspector-api')
const inspector = new Inspector({
    storage: {
        type: 's3',
        bucket: 'testBucket',
        dir: 'inspector'
    }
})

await inspector.profiler.enable()
await inspector.profiler.start()
// Invoke business logic under measurement here...

// some time later...
await inspector.profiler.stop()

Warning: it seems that the new AWS SDK leads to unexpected error if you use the takeSnapshot method (you should use memory sampling)

Constructor's config

new inspector([config])
config.storage
OptiondescriptionDefault value
typeStorage type (raw, s3 or fs)raw
bucketS3 bucket's namenone
dirDirectory where to store the filenone

If you use fs, the generated data will be store on the disk in your default tmp directory. You can display it in Node.js with the command require('os').tmpdir()

Test

$ npm test

Coverage report can be found in coverage/.

Keywords

FAQs

Last updated on 28 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc