mirror of
https://github.com/whscullin/apple2js.git
synced 2024-01-12 14:14:38 +00:00
Better stats.
This commit is contained in:
parent
f75a2fa962
commit
d15979d67e
@ -83,7 +83,7 @@
|
|||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="inset">
|
<div class="inset">
|
||||||
<div id="khz" onclick="Apple2.toggleShowFPS()">0KHz</div>
|
<div id="khz" onclick="Apple2.toggleShowFPS()">0 kHz</div>
|
||||||
<button id="pause-run" onclick="Apple2.pauseRun()" title="Pause/Run">
|
<button id="pause-run" onclick="Apple2.pauseRun()" title="Pause/Run">
|
||||||
<i class="fas fa-pause"></i>
|
<i class="fas fa-pause"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div style="position: relative">
|
<div style="position: relative">
|
||||||
<div id="controls" class="inset">
|
<div id="controls" class="inset">
|
||||||
<div id="khz" onclick="Apple2.toggleShowFPS()">0KHz</div>
|
<div id="khz" onclick="Apple2.toggleShowFPS()">0 kHz</div>
|
||||||
<button id="pause-run" onclick="Apple2.pauseRun()">
|
<button id="pause-run" onclick="Apple2.pauseRun()">
|
||||||
<i class="fas fa-pause"></i>
|
<i class="fas fa-pause"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -9,6 +9,7 @@ import SYMBOLS from './symbols';
|
|||||||
|
|
||||||
export function Apple2(options) {
|
export function Apple2(options) {
|
||||||
var stats = {
|
var stats = {
|
||||||
|
frames: 0,
|
||||||
renderedFrames: 0
|
renderedFrames: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,6 +116,7 @@ export function Apple2(options) {
|
|||||||
stats.renderedFrames++;
|
stats.renderedFrames++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stats.frames++;
|
||||||
io.tick();
|
io.tick();
|
||||||
options.tick();
|
options.tick();
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ var focused = false;
|
|||||||
var startTime = Date.now();
|
var startTime = Date.now();
|
||||||
var lastCycles = 0;
|
var lastCycles = 0;
|
||||||
var lastFrames = 0;
|
var lastFrames = 0;
|
||||||
|
var lastRenderedFrames = 0;
|
||||||
|
|
||||||
var hashtag;
|
var hashtag;
|
||||||
|
|
||||||
@ -267,31 +268,44 @@ function openManage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var prefs = new Prefs();
|
var prefs = new Prefs();
|
||||||
var showFPS = false;
|
var showStats = 0;
|
||||||
|
|
||||||
export function updateKHz() {
|
export function updateKHz() {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
var ms = now - startTime;
|
var ms = now - startTime;
|
||||||
var cycles = cpu.cycles();
|
var cycles = cpu.cycles();
|
||||||
var delta;
|
var delta;
|
||||||
|
var fps;
|
||||||
|
var khz;
|
||||||
|
|
||||||
if (showFPS) {
|
switch (showStats) {
|
||||||
delta = stats.renderedFrames - lastFrames;
|
case 0: {
|
||||||
var fps = parseInt(delta/(ms/1000), 10);
|
|
||||||
document.querySelector('#khz').innerText = fps + 'fps';
|
|
||||||
} else {
|
|
||||||
delta = cycles - lastCycles;
|
delta = cycles - lastCycles;
|
||||||
var khz = parseInt(delta/ms);
|
khz = parseInt(delta/ms);
|
||||||
document.querySelector('#khz').innerText = khz + 'KHz';
|
document.querySelector('#khz').innerText = khz + ' kHz';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
delta = stats.renderedFrames - lastRenderedFrames;
|
||||||
|
fps = parseInt(delta/(ms/1000), 10);
|
||||||
|
document.querySelector('#khz').innerText = fps + ' rps';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
delta = stats.frames - lastFrames;
|
||||||
|
fps = parseInt(delta/(ms/1000), 10);
|
||||||
|
document.querySelector('#khz').innerText = fps + ' fps';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
startTime = now;
|
startTime = now;
|
||||||
lastCycles = cycles;
|
lastCycles = cycles;
|
||||||
lastFrames = stats.renderedFrames;
|
lastRenderedFrames = stats.renderedFrames;
|
||||||
|
lastFrames = stats.frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toggleShowFPS() {
|
export function toggleShowFPS() {
|
||||||
showFPS = !showFPS;
|
showStats = ++showStats % 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateSound() {
|
export function updateSound() {
|
||||||
|
Loading…
Reference in New Issue
Block a user