From 18e561d89d4065c3372da1a1d66d36e3b14a78be Mon Sep 17 00:00:00 2001 From: Uri Shaked Date: Sun, 1 Dec 2019 23:55:42 +0200 Subject: feat(demo): show simulation speed --- demo/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'demo/src/index.ts') 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}%)`; }); } -- cgit v1.2.3