aboutsummaryrefslogtreecommitdiff
path: root/demo/src/index.ts
diff options
context:
space:
mode:
authorUri Shaked2019-12-01 23:55:42 +0200
committerUri Shaked2019-12-01 23:55:42 +0200
commit18e561d89d4065c3372da1a1d66d36e3b14a78be (patch)
tree3857da77fc73a4788f9b34e4e56a030119b4b96c /demo/src/index.ts
parentfeat: improve benchmark code (diff)
downloadavr8js-18e561d89d4065c3372da1a1d66d36e3b14a78be.tar.gz
avr8js-18e561d89d4065c3372da1a1d66d36e3b14a78be.tar.bz2
avr8js-18e561d89d4065c3372da1a1d66d36e3b14a78be.zip
feat(demo): show simulation speed
Diffstat (limited to 'demo/src/index.ts')
-rw-r--r--demo/src/index.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/demo/src/index.ts b/demo/src/index.ts
index 7b6f9b1..a173f04 100644
--- a/demo/src/index.ts
+++ b/demo/src/index.ts
@@ -3,6 +3,7 @@ import { AVRRunner } from './execute';
import { formatTime } from './format-time';
import './index.css';
import { LED } from './led';
+import { CPUPerformance } from './cpu-performance';
let editor: any;
const BLINK_CODE = `
@@ -68,9 +69,11 @@ function executeProgram(hex: string) {
runner.usart.onByteTransmit = (value) => {
serialOutputText.textContent += String.fromCharCode(value);
};
+ const cpuPerf = new CPUPerformance(runner.cpu, MHZ);
runner.execute((cpu) => {
const time = formatTime(cpu.cycles / MHZ);
- statusLabel.textContent = 'Simulation time: ' + time;
+ const speed = (cpuPerf.update() * 100).toFixed(0);
+ statusLabel.textContent = `Simulation time: ${time} (${speed}%)`;
});
}