About genet


Genet is a Node.js profiling tool and it can help to identify bottlenecks in your application.

Let’s look at a simple example of how we can use this tool to help us…

App example:

Let’s add the Genet code to see how long does this code execution while trying to access the URL ‘/’.

When running this app and accessing the URL ‘http://localhost:3000/’ we can see:

Now looking on the app root directory we have two new files:

The prof-1487289189464.cpuprofile with the content generated by v8-profiler and the prof-1487289189464.cpuprofile.txt file which we have a long table with function execution time and the corresponding source code line, look:

To be more clear about our code appear on the table, let’s create a
function called foo and add some code to it.

When running the app and accessing the URL ‘/’ again,
we can see our function foo with 1 millisecond of execution time.


But Genet has more surprises…

If we initialize Genet with verbose:true, we can see the same table on console output:

We can also filter the table to focus more on our application code, in this case
we are going to exclude all express stuff:

Running again we can see the difference:


Now let’s go to make the foo function a bit more slow and run our app again…

Yup, other functions now are showing on the table too…

To finish this simple blog post, let’s generate a flamegraph :]

Just add flamegraph: true option:

And running again we can see a SVG file created on the app root directory:

More about flamegraphs: http://www.brendangregg.com/flamegraphs.html

Leave a Reply