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>
|
||||
<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">
|
||||
<i class="fas fa-pause"></i>
|
||||
</button>
|
||||
|
@ -86,7 +86,7 @@
|
||||
</div>
|
||||
<div style="position: relative">
|
||||
<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()">
|
||||
<i class="fas fa-pause"></i>
|
||||
</button>
|
||||
|
@ -9,6 +9,7 @@ import SYMBOLS from './symbols';
|
||||
|
||||
export function Apple2(options) {
|
||||
var stats = {
|
||||
frames: 0,
|
||||
renderedFrames: 0
|
||||
};
|
||||
|
||||
@ -115,6 +116,7 @@ export function Apple2(options) {
|
||||
stats.renderedFrames++;
|
||||
}
|
||||
}
|
||||
stats.frames++;
|
||||
io.tick();
|
||||
options.tick();
|
||||
|
||||
|
@ -17,6 +17,7 @@ var focused = false;
|
||||
var startTime = Date.now();
|
||||
var lastCycles = 0;
|
||||
var lastFrames = 0;
|
||||
var lastRenderedFrames = 0;
|
||||
|
||||
var hashtag;
|
||||
|
||||
@ -267,31 +268,44 @@ function openManage() {
|
||||
}
|
||||
|
||||
var prefs = new Prefs();
|
||||
var showFPS = false;
|
||||
var showStats = 0;
|
||||
|
||||
export function updateKHz() {
|
||||
var now = Date.now();
|
||||
var ms = now - startTime;
|
||||
var cycles = cpu.cycles();
|
||||
var delta;
|
||||
var fps;
|
||||
var khz;
|
||||
|
||||
if (showFPS) {
|
||||
delta = stats.renderedFrames - lastFrames;
|
||||
var fps = parseInt(delta/(ms/1000), 10);
|
||||
document.querySelector('#khz').innerText = fps + 'fps';
|
||||
} else {
|
||||
switch (showStats) {
|
||||
case 0: {
|
||||
delta = cycles - lastCycles;
|
||||
var khz = parseInt(delta/ms);
|
||||
document.querySelector('#khz').innerText = khz + 'KHz';
|
||||
khz = parseInt(delta/ms);
|
||||
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;
|
||||
lastCycles = cycles;
|
||||
lastFrames = stats.renderedFrames;
|
||||
lastRenderedFrames = stats.renderedFrames;
|
||||
lastFrames = stats.frames;
|
||||
}
|
||||
|
||||
export function toggleShowFPS() {
|
||||
showFPS = !showFPS;
|
||||
showStats = ++showStats % 3;
|
||||
}
|
||||
|
||||
export function updateSound() {
|
||||
|
Loading…
Reference in New Issue
Block a user