1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

speed up debug window - only process required number of messages (#1378)

* speed up debug window - only process required number of messages

* tiny optimisation to debug utils stack handler

* remove unnecessary callback

(and rename function)
This commit is contained in:
Dave Conway-Jones 2017-10-10 21:53:25 +01:00 committed by Nick O'Leary
parent ae7c298b1a
commit 6a869e120c

View File

@ -29,6 +29,7 @@ RED.debug = (function() {
var messagesByNode = {}; var messagesByNode = {};
var sbc; var sbc;
var activeWorkspace; var activeWorkspace;
var numMessages = 100; // Hardcoded number of message to show in debug window scrollback
var filterVisible = false; var filterVisible = false;
@ -369,9 +370,24 @@ RED.debug = (function() {
}) })
menuOptionMenu.show(); menuOptionMenu.show();
} }
function handleDebugMessage(o) {
var msg = document.createElement("div");
var stack = [];
var busy = false;
function handleDebugMessage(o) {
if (o) { stack.push(o); }
if (!busy && (stack.length > 0)) {
busy = true;
processDebugMessage(stack.shift());
setTimeout(function() {
busy = false;
handleDebugMessage();
}, 15); // every 15mS = 66 times a second
if (stack.length > numMessages) { stack = stack.splice(-numMessages); }
}
}
function processDebugMessage(o) {
var msg = document.createElement("div");
var sourceNode = o._source; var sourceNode = o._source;
msg.onmouseenter = function() { msg.onmouseenter = function() {
@ -497,7 +513,7 @@ RED.debug = (function() {
} }
} }
if (messages.length === 100) { if (messages.length === numMessages) {
m = messages.shift(); m = messages.shift();
if (view === "list") { if (view === "list") {
m.el.remove(); m.el.remove();
@ -506,12 +522,13 @@ RED.debug = (function() {
if (atBottom) { if (atBottom) {
messageList.scrollTop(sbc.scrollHeight); messageList.scrollTop(sbc.scrollHeight);
} }
if (cb) { cb(); }
} }
return { return {
init: init, init: init,
refreshMessageList:refreshMessageList, refreshMessageList:refreshMessageList,
handleDebugMessage: handleDebugMessage, handleDebugMessage: handleDebugMessage
} }
})(); })();