yahoo/mojito — pull request #474 by caridy (2012-09-10 18:02:53+00:00)
Title: Performance metrics in mojito

Getting perf.server.js as expected. Adding new configuration settings to enable and disable some of the metrics:

[{
"settings": [ "master" ],
"specs": {},
"perf": {
"timeline": true,
"mark": true
}
}]

With these new settings, we can get some useful metrics through the Node console. We can also instrument any mojit or any mojito-core related process by using `mark` or `timeline` methods. Here is an example:

YUI.add('something', function(Y, NAME) {

// mark an important moment in the request life-cycle
Y.mojito.perf.mark(NAME, 'metric-name',
'metric description', 'uniqueId if needed');

// open a timeline metric if you want to measure a process
var perf = Y.mojito.perf.timeline(NAME, 'metric-name',
'metric description', 'uniqueId if needed');

// at some point in the future, you can call "done"
// to mark the end of the timeline.
perf.done();

}, '0.1.0', {requires: [
'mojito-perf',
]});

As a result, we will get something like this in the console:

[MOJITO] (11) mojito-perf: something:metricName[id] mark=120 (metric description)
[MOJITO] (12) mojito-perf: something:metricName[id] timeline=300 (metric description)
[MOJITO] (14) mojito-perf: mojito:mojito-perf:express:timeline[1] timeline=420 (time to respond)