Skip to content

Commit

Permalink
Better logging performance
Browse files Browse the repository at this point in the history
  • Loading branch information
vanevery committed Oct 4, 2016
1 parent 05044e4 commit a4c407b
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
var sendMessage;
var sendButton;

// var consoleBuffer = [];
// var lastConsoleLogTime = Date.now();
// var LOGWAIT = 2000;
var consoleBuffer = [];
var lastConsoleLogTime = Date.now();
var LOGWAIT = 500;

function setup() {
createCanvas(1, 1);
Expand Down Expand Up @@ -222,26 +222,26 @@
//console.log(txt + "\n");
if (serialConsoleEnabled) {

if (serialConsole.elt.value.length >= 800)
{
serialConsole.elt.value = serialConsole.elt.value.substring(400);
}
serialConsole.elt.value += txt + "\n";
serialConsole.elt.scrollTop = serialConsole.elt.scrollHeight;

// consoleBuffer.push(txt);
// if (lastConsoleLogTime + LOGWAIT < Date.now()) {
// if (serialConsole.elt.value.length >= 800)
// {
// serialConsole.elt.value = serialConsole.elt.value.substring(400);
// }
// serialConsole.elt.value += consoleBuffer.join("\n");
// serialConsole.elt.scrollTop = serialConsole.elt.scrollHeight;
//
// lastConsoleLogTime = Date.now();
// consoleBuffer.length = 0;
// console.log("wrote to text area " + consoleBuffer.length);
// if (serialConsole.elt.value.length >= 800)
// {
// serialConsole.elt.value = serialConsole.elt.value.substring(400);
// }
// serialConsole.elt.value += txt + "\n";
// serialConsole.elt.scrollTop = serialConsole.elt.scrollHeight;

consoleBuffer.push(txt);
if (lastConsoleLogTime + LOGWAIT < Date.now()) {
if (serialConsole.elt.value.length >= 800)
{
serialConsole.elt.value = serialConsole.elt.value.substring(400);
}
serialConsole.elt.value += consoleBuffer.join("\n");
serialConsole.elt.scrollTop = serialConsole.elt.scrollHeight;

lastConsoleLogTime = Date.now();
consoleBuffer.length = 0;
console.log("wrote to text area " + consoleBuffer.length);
}
}
}

Expand Down

0 comments on commit a4c407b

Please sign in to comment.