Run profiler while prelude is loading

This commit is contained in:
2026-03-19 22:03:46 +00:00
parent d39fe580fc
commit 87d8345017

15
emu.js
View File

@@ -51,6 +51,19 @@ class Emulator {
document.addEventListener('keydown', (e) => this.handle_keydown(e)); document.addEventListener('keydown', (e) => this.handle_keydown(e));
window.addEventListener('resize', () => this.handle_resize()); window.addEventListener('resize', () => this.handle_resize());
this.prof = new Worker("prof.js");
this.prof.onmessage = (e) => {
const blob = new Blob(
[JSON.stringify(e.data)],
{ type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "wipforth-profile.json";
a.click();
URL.revokeObjectURL(url);
};
this.print("Assembling kernel "); this.print("Assembling kernel ");
const dots = setInterval(() => this.print("."), DOT_INTERVAL_MS); const dots = setInterval(() => this.print("."), DOT_INTERVAL_MS);
this.worker = new Worker('boot.js', { type: 'module' }); this.worker = new Worker('boot.js', { type: 'module' });
@@ -59,6 +72,7 @@ class Emulator {
clearInterval(dots); clearInterval(dots);
this.print(" done\n"); this.print(" done\n");
this.worker.postMessage({ type: "boot" }); this.worker.postMessage({ type: "boot" });
this.prof.postMessage({ type: "start", mem: this.mem });
}; };
fetch('prelude.f') fetch('prelude.f')
@@ -85,6 +99,7 @@ class Emulator {
if (!this.input_enable) { if (!this.input_enable) {
const sysready = Atomics.load(this.mem_u8, SYSREADY); const sysready = Atomics.load(this.mem_u8, SYSREADY);
if (sysready != 0) { if (sysready != 0) {
this.prof.postMessage({ type: "stop" });
this.input_enable = true; this.input_enable = true;
this.flush_output(); this.flush_output();
document.getElementById('cursor').classList.add('blinking'); document.getElementById('cursor').classList.add('blinking');