0.2.2 • Published 4 years ago

node-quickprofiler v0.2.2

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Quick profiler

Promisifies the inspector library and implements the boiler plate for you; then you can make simpler calls to get memory and CPU profiling information ready to be visualized in Google Chrome. All reports are returned as a stringified version of the JSON response to be ready to be stored in a file or returned in a REST endpoint.

Example:

const Profiler = require('./profiler').Profiler;
const fs = require('fs');

const profiler = new Profiler();

profiler.on('ready', _ => {
    console.log('profiler ready');
});

profiler.init();

setTimeout(async () => {
	try {
		const report = await profiler.sampleCPU(10);
		fs.writeFileSync('profile.cpuprofile', report);
	} catch(e) {
		console.error(e);
	}
}, 4000); // Doing this to capture a sample later

Methods:

sampleCPU(time_seconds)

Captures a CPU profile for the amount of time specified by the argument, the default value is 30.

sampleMemory(time_seconds)

Captures a CPU profile for the amount of time specified by the argument, the default value is 30.

memorySnapshot

Captures a memory snapshot. Takes no argument.

collectGarbage

Calls for garbage collection. Takes no argument.

Suggested filename

TypeFile name
Heap snapshotsnapshot.heapsnapshot
Memory profilingprofile.heaptimeline
CPU profilingprofile.cpuprofile
0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago