mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-28 07:21:02 +00:00
Print memory stats
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { EmulationStatus } from "@/emulator";
|
||||
import { TextTooltip } from "./text-tooltip";
|
||||
import { BarChartSteps, CpuFill } from "react-bootstrap-icons";
|
||||
import { BarChartSteps, CpuFill, FloppyFill } from "react-bootstrap-icons";
|
||||
|
||||
import "./emulation-summary.css";
|
||||
|
||||
@@ -8,6 +8,20 @@ export interface EmulationSummaryProps {
|
||||
status?: EmulationStatus;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
export function EmulationSummary(props: EmulationSummaryProps) {
|
||||
if (!props.status) {
|
||||
return <></>;
|
||||
@@ -20,6 +34,11 @@ export function EmulationSummary(props: EmulationSummaryProps) {
|
||||
<BarChartSteps className="inline ml-3" />
|
||||
</TextTooltip>
|
||||
<br />
|
||||
<TextTooltip tooltip={"Application memory"}>
|
||||
{formatMemory(props.status.committedMemory)}
|
||||
<FloppyFill className="inline ml-3" />
|
||||
</TextTooltip>
|
||||
<br />
|
||||
<TextTooltip tooltip={"Executed instructions"}>
|
||||
{props.status.executedInstructions.toLocaleString()}
|
||||
<CpuFill className="inline ml-3" />
|
||||
|
||||
Reference in New Issue
Block a user