Damage
Find out what is killing your Node.JS process.
A simple way to profile the damage of running a task in a Node.JS instance.
How it works
When you request a new damage calculation it follow these steps:
- Creates a script prepared to handle the test.
- Fork it.
- Execute it gathering process information.
- Process the result.
- Print/emit the result.
Quick start
Installing
With Node.JS and NPM installed, type:
$ npm install damage
Configuring the damage
Use this to get the Damage constructor.
var Damage = ;
Then you can use prepare()
to define a preparation task
to run before each collection of tasks.
Damage;
Then finally you can just get your damageOf()
function, that you need to create damage tests.
var damageOf = ;
Now that you have the function, just use it with a description
, a damage test function
and the number of damage repeats
, just like this:
;
Remember: Inside the test function you need to call done()
after you finish the task.
Result of that damage
Features
Configuration
You can change the global configuration of Damage with this:
Damage;
To see all Damage's configuration, read this configuration file.
Environment
You can change the Damage environment object with this:
Damage;
Then when you can access env variables like this:
var damageOf = ;;
Preparation Script
You can change the Damage environment object with this:
Damage;
Defining where test begins
Some cases you'll need to do specific task that can not be placed inside prepare()
becuse is not used in other tasks.
For those cases you can use start()
to define where the test really begins.
Just like this:
var damageOf = ;Damage;
Add the start()
to define that test will start now.
... ; ...
Now the real test begins.
... for o in obj objo=Numberobjo; ; // And stops here.}1000);
Inspecting the result
You can listen for the final processed and full result of each damage test using this:
// Add this after the damageOf() call
Dumping memory heap
Now you can get a heap snapshot file for each task. Just define the following configurations:
Damage;
Examples
There are some examples here. =)