Reputation: 71
I'm debugging some dustjs template render sluggishness after calling res.render from an express controller. There are a few (fast) async calls from dust helpers, but even when they're removed I'm occasionally seeing templates take multiple seconds to render, which is surprising since they're all pre-compiled.
Is there any built in timing/logging for dustjs or do I just need to profile the entire application?
Upvotes: 0
Views: 87
Reputation: 17434
You can add some simple profiling in Node by monkey-patching dust.render
like this:
var dust = require('dustjs-linkedin');
var render = dust.render;
dust.render = function(name, context, callback) {
var timeStart = process.hrtime();
render(name, context, function() {
var timeDiff = process.hrtime(timeStart);
console.log(name, timeDiff[0] * 1000 + timeDiff[1] / 1000000);
callback.apply(undefined, arguments);
});
};
When you run your application, look at the console to see how much time rendering takes. Rendering a normal Dust template takes on the order of milliseconds.
> node app.js
hello 0.832608
Hello world! Using Dust version 2.7.1!
This template took 0.8ms to render.
Upvotes: 1