This commit is contained in:
Michael Bebenita 2015-01-08 16:49:27 -08:00
Родитель dcd02fd608
Коммит 42223bdff8
4 изменённых файлов: 84 добавлений и 21 удалений

Просмотреть файл

@ -169,6 +169,8 @@
this.count = 0;
window.addEventListener(
'console-clear', this.onClear.bind(this));
window.addEventListener(
'console-save', this.onSave.bind(this));
}
var contextColors = ["#111111", "#222222", "#333333", "#444444", "#555555", "#666666"];
@ -195,11 +197,17 @@
toRGB565(0xFF, 0, 0),
toRGB565(0, 0, 0),
];
var lastTime = 0;
TerminalConsole.prototype = {
push: function(item) {
if (item.matchesCurrentFilters()) {
this.buffer.color = colors[item.logLevel];
this.buffer.writeString(item.logLevel + " " + item.message);
var thisTime = performance.now();
var prefix = (thisTime - lastTime).toFixed(2) + " : ";
prefix = "";
lastTime = thisTime;
this.buffer.writeString(prefix.padLeft(" ", 4) + item.logLevel + " " + item.message);
this.buffer.writeLine();
this.view.scrollToBottom();
}
@ -207,6 +215,16 @@
onClear: function() {
this.buffer.clear();
this.view.scrollToBottom();
},
onSave: function() {
var string = this.buffer.toString();
var b = this.buffer;
var l = [];
for (var i = 0; i < b.h; i++) {
l.push(b.getLine(i));
}
window.open(URL.createObjectURL(new Blob([l.join("\n")], {type:'text/plain'})));
}
}
@ -234,6 +252,10 @@
window.dispatchEvent(new CustomEvent('console-clear'));
});
document.querySelector('#console-save').addEventListener('click', function() {
window.dispatchEvent(new CustomEvent('console-save'));
});
var logLevelSelect = document.querySelector('#loglevel');
function updateFilters() {
minLogLevel = logLevelSelect.value;

Просмотреть файл

@ -146,6 +146,16 @@ var Terminal;
this.starts[++this.h] = this.i;
this.version++;
};
Buffer.prototype.getLine = function (l) {
l = clamp(l, 0, this.h - 1);
var s = this.starts[l];
var e = i === this.h - 1 ? this.i : this.starts[l + 1];
var c = [];
for (var i = s; i < e; i++) {
c.push(String.fromCharCode(this.buffer[i]));
}
return c.join("");
};
return Buffer;
})();
Terminal.Buffer = Buffer;

Просмотреть файл

@ -106,6 +106,7 @@
</select>
<input id="console-filter-input" type="text" placeholder="Filter Console Output" value="">
<button id="console-clear">Clear console</button>
<button id="console-save">Save console</button>
<label><input type="checkbox" id="perfWriter">Perf</label>
</section>
<section>
@ -119,7 +120,8 @@
<button id="profile">Profile: OFF</button>
<button id="clearCounters">Clear Counters</button>
<button id="dumpCounters">Dump Counters</button>
<button id="dumpCountersTime">Dump Counters Time</button>
<button id="sampleCounters1">One sample for 1s</button>
<button id="sampleCounters2">One sample for 100ms (2s)</button>
<button id="start">Start</button>
<button id="loadAllClasses">Load All Classes</button>
</section>

67
main.js
Просмотреть файл

@ -240,31 +240,60 @@ window.onload = function() {
toggle(this);
};
document.getElementById("clearCounters").onclick = function() {
J2ME.interpreterCounter.clear();
J2ME.runtimeCounter && J2ME.runtimeCounter.clear();
J2ME.nativeCounter && J2ME.nativeCounter.clear();
J2ME.interpreterCounter && J2ME.interpreterCounter.clear();
};
document.getElementById("dumpCounters").onclick = function() {
if (J2ME.interpreterCounter) {
J2ME.interpreterCounter.traceSorted(new J2ME.IndentingWriter());
}
if (J2ME.nativeCounter) {
J2ME.nativeCounter.traceSorted(new J2ME.IndentingWriter());
}
if (J2ME.runtimeCounter) {
J2ME.runtimeCounter.traceSorted(new J2ME.IndentingWriter());
}
};
document.getElementById("dumpCountersTime").onclick = function() {
function dumpCounters() {
var writer = new J2ME.IndentingWriter();
if (J2ME.interpreterCounter) {
writer.enter("interpreterCounter");
J2ME.interpreterCounter.traceSorted(writer);
writer.outdent();
}
if (J2ME.nativeCounter) {
writer.enter("nativeCounter");
J2ME.nativeCounter.traceSorted(writer);
writer.outdent();
}
if (J2ME.runtimeCounter) {
writer.enter("runtimeCounter");
J2ME.runtimeCounter.traceSorted(writer);
writer.outdent();
}
}
function clearCounters() {
J2ME.interpreterCounter && J2ME.interpreterCounter.clear();
J2ME.nativeCounter && J2ME.nativeCounter.clear();
J2ME.runtimeCounter && J2ME.runtimeCounter.clear();
}
document.getElementById("dumpCounters").onclick = function() {
dumpCounters();
};
document.getElementById("sampleCounters1").onclick = function() {
clearCounters();
dumpCounters();
setTimeout(function () {
if (J2ME.interpreterCounter) {
J2ME.interpreterCounter.traceSorted(new J2ME.IndentingWriter());
}
if (J2ME.nativeCounter) {
J2ME.nativeCounter.traceSorted(new J2ME.IndentingWriter());
}
dumpCounters();
}, 1000);
};
document.getElementById("sampleCounters2").onclick = function() {
clearCounters();
function sample() {
var c = 1;
function tick() {
if (c-- > 0) {
dumpCounters();
clearCounters();
setTimeout(tick, 16);
}
}
setTimeout(tick, 100);
}
setTimeout(sample, 2000); // Wait 2s before starting.
};
document.getElementById("profile").onclick = function() {
if (getIsOff(this)) {
Instrument.startProfile();