nps-reader

A Node.JS library for parsing NPS snapshots generated by Java VisualVM

Usage no npm install needed!

<script type="module">
  import npsReader from 'https://cdn.skypack.dev/nps-reader';
</script>

README

nps-reader

This small library with no external dependecies is intended to help decoding NPS snapshots used by Java VisualVM tool. Currently it only supports decoding CPU profiles.

Based on VisualVM source code.

Currently there's pretty much the only method in this library: NPS.readFromBuffer(buffer). It accepts a buffer as a single argument and returns the corresponding data structure.

Usage:

const fs = require('fs');
const util = require('util');
const NPS = require('nps-reader');

const samples = fs.readFileSync('sampler-snapshot_18.nps');

const data = NPS.readFromBuffer(samples);

console.log(util.inspect(data, { colors: true, depth: 5 }));

The main purpose of this library was to visualise snapshots generated by Sampler mod for Minecraft (without the need to use VisualVM itself).

TBD

  • Parsing other types of snapshots
  • Saving snapshots
  • Adding async methods