-
Notifications
You must be signed in to change notification settings - Fork 33
/
vuvuzela.js
46 lines (40 loc) · 1.37 KB
/
vuvuzela.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Vuvuzela
*
* Make the Ember Runloop noisy on the console to help visualise its action.
*
* This patch will seriously degrade the performance of your Ember application
* so should never be applied to production code.
*
*/
Vuvuzela = (function () {
var bb = Ember.run.backburner,
oldBegin = bb.begin,
oldEnd = bb.end,
oldFlush = bb.flush,
runLoopId = 0;
Ember.run.backburner.begin = function () {
oldBegin.apply(bb, arguments);
bb.currentInstance.__uniqueId = ++runLoopId;
Ember.debug('Opening queues in Runloop: ' + bb.currentInstance.__uniqueId);
};
Ember.run.backburner.end = function () {
var currentId = bb.currentInstance.__uniqueId;
Ember.debug('Closing queues in Runloop ' + currentId + ' to outside code');
Ember.debug('The queues look like:' + queuesReport());
oldEnd.apply(bb, arguments);
};
Ember.run.backburner.flush = function () {
var currentId = bb.currentInstance.__uniqueId;
Ember.debug('Flushing queues in Runloop: ' + currentId);
oldFlush.apply(bb, arguments);
};
function queuesReport() {
var names = Ember.run.queues;
var queues = Ember.run.backburner.currentInstance.queues;
var reports = names.map(function (name) {
return name + ": items:" + queues[name]._queue.length + " (4 items per job)\n";
});
return reports.join('\n* ');
}
}());