import { EmulationStatus } from "@/emulator"; import { TextTooltip } from "./text-tooltip"; import { BarChartSteps, CpuFill, FloppyFill, StopwatchFill, } from "react-bootstrap-icons"; import React from "react"; export interface EmulationSummaryProps { status?: EmulationStatus; executionTimeFetcher: () => number; } function formatMemory(value: BigInt): string { const abbr = ["B", "KB", "MB", "GB", "PB"]; let num = Number(value); let index = 0; while (num >= 1024 && index < abbr.length - 1) { num /= 1024; index++; } return num.toFixed(2) + " " + abbr[index]; } function formatTime(seconds: number): string { const hrs = Math.floor(seconds / 3600); const mins = Math.floor((seconds % 3600) / 60); const secs = Math.floor(seconds % 60); const secsString = secs < 10 ? "0" + secs : secs.toString(); if (hrs > 0) { const minsString = mins < 10 ? "0" + mins : mins.toString(); return `${hrs.toString()}:${minsString}:${secsString}`; } return `${mins.toString()}:${secsString}`; } export class EmulationSummary extends React.Component< EmulationSummaryProps, {} > { private timer: NodeJS.Timeout | undefined = undefined; constructor(props: EmulationSummaryProps) { super(props); } componentDidMount(): void { if (this.timer) { clearInterval(this.timer); } this.timer = setInterval(() => { this.forceUpdate(); }, 200); } componentWillUnmount(): void { if (this.timer) { clearInterval(this.timer); this.timer = undefined; } } render() { if (!this.props.status) { return <>>; } return (