refactor: rename state.svelte.ts to graph-state.svelte.ts
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 1m59s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 1m59s
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
import { HTML } from "@threlte/extras";
|
import { HTML } from "@threlte/extras";
|
||||||
import { onMount } from "svelte";
|
import { onMount } from "svelte";
|
||||||
import type { NodeInstance, NodeId } from "@nodarium/types";
|
import type { NodeInstance, NodeId } from "@nodarium/types";
|
||||||
import { getGraphManager, getGraphState } from "../graph/state.svelte";
|
import { getGraphManager, getGraphState } from "../graph-state.svelte";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
onnode: (n: NodeInstance) => void;
|
onnode: (n: NodeInstance) => void;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { NodeInstance, Socket } from "@nodarium/types";
|
import type { NodeInstance, Socket } from "@nodarium/types";
|
||||||
import { getContext, setContext } from "svelte";
|
import { getContext, setContext } from "svelte";
|
||||||
import { SvelteSet } from "svelte/reactivity";
|
import { SvelteSet } from "svelte/reactivity";
|
||||||
import type { GraphManager } from "../graph-manager.svelte";
|
import type { GraphManager } from "./graph-manager.svelte";
|
||||||
import type { OrthographicCamera } from "three";
|
import type { OrthographicCamera } from "three";
|
||||||
|
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
import Camera from "../components/Camera.svelte";
|
import Camera from "../components/Camera.svelte";
|
||||||
import { Canvas } from "@threlte/core";
|
import { Canvas } from "@threlte/core";
|
||||||
import HelpView from "../components/HelpView.svelte";
|
import HelpView from "../components/HelpView.svelte";
|
||||||
import { getGraphManager, getGraphState } from "./state.svelte";
|
import { getGraphManager, getGraphState } from "../graph-state.svelte";
|
||||||
import { HTML } from "@threlte/extras";
|
import { HTML } from "@threlte/extras";
|
||||||
import { FileDropEventManager, MouseEventManager } from "./events";
|
import { FileDropEventManager, MouseEventManager } from "./events";
|
||||||
import { maxZoom, minZoom } from "./constants";
|
import { maxZoom, minZoom } from "./constants";
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
import GraphEl from "./Graph.svelte";
|
import GraphEl from "./Graph.svelte";
|
||||||
import { GraphManager } from "../graph-manager.svelte";
|
import { GraphManager } from "../graph-manager.svelte";
|
||||||
import { createKeyMap } from "$lib/helpers/createKeyMap";
|
import { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||||
import { GraphState, setGraphManager, setGraphState } from "./state.svelte";
|
import {
|
||||||
|
GraphState,
|
||||||
|
setGraphManager,
|
||||||
|
setGraphState,
|
||||||
|
} from "../graph-state.svelte";
|
||||||
import { setupKeymaps } from "../keymaps";
|
import { setupKeymaps } from "../keymaps";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { GraphSchema, type NodeId, type NodeInstance } from "@nodarium/types";
|
import { GraphSchema, type NodeId, type NodeInstance } from "@nodarium/types";
|
||||||
import type { GraphManager } from "../graph-manager.svelte";
|
import type { GraphManager } from "../graph-manager.svelte";
|
||||||
import type { GraphState } from "./state.svelte";
|
import type { GraphState } from "../graph-state.svelte";
|
||||||
import { animate, lerp } from "$lib/helpers";
|
import { animate, lerp } from "$lib/helpers";
|
||||||
import { snapToGrid as snapPointToGrid } from "../helpers";
|
import { snapToGrid as snapPointToGrid } from "../helpers";
|
||||||
import { maxZoom, minZoom, zoomSpeed } from "./constants";
|
import { maxZoom, minZoom, zoomSpeed } from "./constants";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { animate, lerp } from "$lib/helpers";
|
|||||||
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
import type { createKeyMap } from "$lib/helpers/createKeyMap";
|
||||||
import FileSaver from "file-saver";
|
import FileSaver from "file-saver";
|
||||||
import type { GraphManager } from "./graph-manager.svelte";
|
import type { GraphManager } from "./graph-manager.svelte";
|
||||||
import type { GraphState } from "./graph/state.svelte";
|
import type { GraphState } from "./graph-state.svelte";
|
||||||
|
|
||||||
type Keymap = ReturnType<typeof createKeyMap>;
|
type Keymap = ReturnType<typeof createKeyMap>;
|
||||||
export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: GraphState) {
|
export function setupKeymaps(keymap: Keymap, graph: GraphManager, graphState: GraphState) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { NodeInstance } from "@nodarium/types";
|
import type { NodeInstance } from "@nodarium/types";
|
||||||
import { getGraphState } from "../graph/state.svelte";
|
import { getGraphState } from "../graph-state.svelte";
|
||||||
import { T } from "@threlte/core";
|
import { T } from "@threlte/core";
|
||||||
import { type Mesh } from "three";
|
import { type Mesh } from "three";
|
||||||
import NodeFrag from "./Node.frag";
|
import NodeFrag from "./Node.frag";
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import type { NodeInstance } from "@nodarium/types";
|
import type { NodeInstance } from "@nodarium/types";
|
||||||
import NodeHeader from "./NodeHeader.svelte";
|
import NodeHeader from "./NodeHeader.svelte";
|
||||||
import NodeParameter from "./NodeParameter.svelte";
|
import NodeParameter from "./NodeParameter.svelte";
|
||||||
import { getGraphState } from "../graph/state.svelte";
|
import { getGraphState } from "../graph-state.svelte";
|
||||||
|
|
||||||
let ref: HTMLDivElement;
|
let ref: HTMLDivElement;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getGraphState } from "../graph/state.svelte.js";
|
import { getGraphState } from "../graph-state.svelte";
|
||||||
import { createNodePath } from "../helpers/index.js";
|
import { createNodePath } from "../helpers/index.js";
|
||||||
import type { NodeInstance } from "@nodarium/types";
|
import type { NodeInstance } from "@nodarium/types";
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { NodeInput, NodeInstance } from "@nodarium/types";
|
import type { NodeInput, NodeInstance } from "@nodarium/types";
|
||||||
import { createNodePath } from "../helpers/index.js";
|
import { createNodePath } from "../helpers";
|
||||||
import NodeInputEl from "./NodeInput.svelte";
|
import NodeInputEl from "./NodeInput.svelte";
|
||||||
import { getGraphManager, getGraphState } from "../graph/state.svelte.js";
|
import { getGraphManager, getGraphState } from "../graph-state.svelte";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
node: NodeInstance;
|
node: NodeInstance;
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let labels: string[] = [];
|
type Props = {
|
||||||
export let values: number[] = [];
|
labels: string[];
|
||||||
|
values: number[];
|
||||||
|
};
|
||||||
|
|
||||||
$: total = values.reduce((acc, v) => acc + v, 0);
|
const { labels, values }: Props = $props();
|
||||||
|
|
||||||
|
const total = $derived(values.reduce((acc, v) => acc + v, 0));
|
||||||
|
|
||||||
let colors = ["red", "green", "blue"];
|
let colors = ["red", "green", "blue"];
|
||||||
</script>
|
</script>
|
||||||
@@ -21,10 +25,7 @@
|
|||||||
<div class="text-{colors[i]}">{labels[i]}</div>
|
<div class="text-{colors[i]}">{labels[i]}</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
<span class="bg-red bg-green bg-blue text-red text-green text-blue"></span>
|
||||||
<span
|
|
||||||
class="bg-red bg-green bg-yellow bg-blue text-red text-green text-yellow text-blue"
|
|
||||||
></span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -1,52 +1,59 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let points: number[];
|
type Props = {
|
||||||
|
points: number[];
|
||||||
|
type?: string;
|
||||||
|
title?: string;
|
||||||
|
max?: number;
|
||||||
|
min?: number;
|
||||||
|
};
|
||||||
|
|
||||||
export let type = "ms";
|
let {
|
||||||
export let title = "Performance";
|
points,
|
||||||
export let max: number | undefined = undefined;
|
type = "ms",
|
||||||
export let min: number | undefined = undefined;
|
title = "Performance",
|
||||||
|
max,
|
||||||
|
min,
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
function getMax(m?: number) {
|
let internalMax = $derived(max ?? Math.max(...points));
|
||||||
|
let internalMin = $derived(min ?? Math.min(...points))!;
|
||||||
|
|
||||||
|
const maxText = $derived.by(() => {
|
||||||
if (type === "%") {
|
if (type === "%") {
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m !== undefined) {
|
if (internalMax !== undefined) {
|
||||||
if (m < 1) {
|
if (internalMax < 1) {
|
||||||
return Math.floor(m * 100) / 100;
|
return Math.floor(internalMax * 100) / 100;
|
||||||
}
|
}
|
||||||
if (m < 10) {
|
if (internalMax < 10) {
|
||||||
return Math.floor(m * 10) / 10;
|
return Math.floor(internalMax * 10) / 10;
|
||||||
}
|
}
|
||||||
return Math.floor(m);
|
return Math.floor(internalMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
});
|
||||||
|
|
||||||
function constructPath() {
|
const path = $derived(
|
||||||
max = max !== undefined ? max : Math.max(...points);
|
points
|
||||||
min = min !== undefined ? min : Math.min(...points);
|
|
||||||
const mi = min as number;
|
|
||||||
const ma = max as number;
|
|
||||||
return points
|
|
||||||
.map((point, i) => {
|
.map((point, i) => {
|
||||||
const x = (i / (points.length - 1)) * 100;
|
const x = (i / (points.length - 1)) * 100;
|
||||||
const y = 100 - ((point - mi) / (ma - mi)) * 100;
|
const y =
|
||||||
|
100 - ((point - internalMin) / (internalMax - internalMin)) * 100;
|
||||||
return `${x},${y}`;
|
return `${x},${y}`;
|
||||||
})
|
})
|
||||||
.join(" ");
|
.join(" "),
|
||||||
}
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<p>{title}</p>
|
<p>{title}</p>
|
||||||
<span class="min">{Math.floor(min || 0)}{type}</span>
|
<span class="min">{Math.floor(internalMin || 0)}{type}</span>
|
||||||
<span class="max">{getMax(max)}{type}</span>
|
<span class="max">{maxText}{type}</span>
|
||||||
<svg preserveAspectRatio="none" viewBox="0 0 100 100">
|
<svg preserveAspectRatio="none" viewBox="0 0 100 100">
|
||||||
{#key points}
|
<polyline vector-effect="non-scaling-stroke" points={path} />
|
||||||
<polyline vector-effect="non-scaling-stroke" points={constructPath()} />
|
|
||||||
{/key}
|
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,23 +2,13 @@
|
|||||||
import Monitor from "./Monitor.svelte";
|
import Monitor from "./Monitor.svelte";
|
||||||
import { humanizeNumber } from "$lib/helpers";
|
import { humanizeNumber } from "$lib/helpers";
|
||||||
import { Checkbox } from "@nodarium/ui";
|
import { Checkbox } from "@nodarium/ui";
|
||||||
import localStore from "$lib/helpers/localStore";
|
import type { PerformanceData } from "@nodarium/utils";
|
||||||
import { type PerformanceData } from "@nodarium/utils";
|
|
||||||
import BarSplit from "./BarSplit.svelte";
|
import BarSplit from "./BarSplit.svelte";
|
||||||
|
|
||||||
export let data: PerformanceData;
|
const { data }: { data: PerformanceData } = $props();
|
||||||
|
|
||||||
let activeType = localStore<string>("nodes.performance.active-type", "total");
|
let activeType = $state("total");
|
||||||
let showAverage = true;
|
let showAverage = $state(true);
|
||||||
|
|
||||||
function getAverage(key: string) {
|
|
||||||
return (
|
|
||||||
data
|
|
||||||
.map((run) => run[key]?.[0])
|
|
||||||
.filter((v) => v !== undefined)
|
|
||||||
.reduce((acc, run) => acc + run, 0) / data.length
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function round(v: number) {
|
function round(v: number) {
|
||||||
if (v < 1) {
|
if (v < 1) {
|
||||||
@@ -30,45 +20,15 @@
|
|||||||
return Math.floor(v);
|
return Math.floor(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAverages() {
|
function getTitle(t: string) {
|
||||||
let lastRun = data.at(-1);
|
if (t.includes("/")) {
|
||||||
if (!lastRun) return {};
|
return `Node ${t.split("/").slice(-1).join("/")}`;
|
||||||
return Object.keys(lastRun).reduce(
|
|
||||||
(acc, key) => {
|
|
||||||
acc[key] = getAverage(key);
|
|
||||||
return acc;
|
|
||||||
},
|
|
||||||
{} as Record<string, number>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLast(key: string) {
|
|
||||||
return data.at(-1)?.[key]?.[0] || 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getLasts() {
|
|
||||||
return data.at(-1) || {};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTotalPerformance(onlyLast = false) {
|
|
||||||
if (onlyLast) {
|
|
||||||
return (
|
|
||||||
getLast("runtime") +
|
|
||||||
getLast("update-geometries") +
|
|
||||||
getLast("worker-transfer")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return (
|
|
||||||
getAverage("runtime") +
|
|
||||||
getAverage("update-geometries") +
|
|
||||||
getAverage("worker-transfer")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCacheRatio(onlyLast = false) {
|
return t
|
||||||
let ratio = onlyLast ? getLast("cache-hit") : getAverage("cache-hit");
|
.split("-")
|
||||||
|
.map((v) => v[0].toUpperCase() + v.slice(1))
|
||||||
return Math.floor(ratio * 100);
|
.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
const viewerKeys = [
|
const viewerKeys = [
|
||||||
@@ -78,10 +38,53 @@
|
|||||||
"split-result",
|
"split-result",
|
||||||
];
|
];
|
||||||
|
|
||||||
function getPerformanceData(onlyLast: boolean = false) {
|
// --- Small helpers that query `data` directly ---
|
||||||
let data = onlyLast ? getLasts() : getAverages();
|
function getAverage(key: string) {
|
||||||
|
const vals = data
|
||||||
|
.map((run) => run[key]?.[0])
|
||||||
|
.filter((v) => v !== undefined) as number[];
|
||||||
|
|
||||||
return Object.entries(data)
|
if (vals.length === 0) return 0;
|
||||||
|
return vals.reduce((acc, v) => acc + v, 0) / vals.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLast(key: string) {
|
||||||
|
return data.at(-1)?.[key]?.[0] || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const averages = $derived.by(() => {
|
||||||
|
const lr = data.at(-1);
|
||||||
|
if (!lr) return {} as Record<string, number>;
|
||||||
|
return Object.keys(lr).reduce((acc: Record<string, number>, key) => {
|
||||||
|
acc[key] = getAverage(key);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
});
|
||||||
|
|
||||||
|
const lasts = $derived.by(() => data.at(-1) || {});
|
||||||
|
|
||||||
|
const totalPerformance = $derived.by(() => {
|
||||||
|
const onlyLast =
|
||||||
|
getLast("runtime") +
|
||||||
|
getLast("update-geometries") +
|
||||||
|
getLast("worker-transfer");
|
||||||
|
const average =
|
||||||
|
getAverage("runtime") +
|
||||||
|
getAverage("update-geometries") +
|
||||||
|
getAverage("worker-transfer");
|
||||||
|
return { onlyLast, average };
|
||||||
|
});
|
||||||
|
|
||||||
|
const cacheRatio = $derived.by(() => {
|
||||||
|
return {
|
||||||
|
onlyLast: Math.floor(getLast("cache-hit") * 100),
|
||||||
|
average: Math.floor(getAverage("cache-hit") * 100),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const performanceData = $derived.by(() => {
|
||||||
|
const source = showAverage ? averages : lasts;
|
||||||
|
return Object.entries(source)
|
||||||
.filter(
|
.filter(
|
||||||
([key]) =>
|
([key]) =>
|
||||||
!key.startsWith("node/") &&
|
!key.startsWith("node/") &&
|
||||||
@@ -90,19 +93,18 @@
|
|||||||
!viewerKeys.includes(key),
|
!viewerKeys.includes(key),
|
||||||
)
|
)
|
||||||
.sort((a, b) => b[1] - a[1]);
|
.sort((a, b) => b[1] - a[1]);
|
||||||
}
|
});
|
||||||
|
|
||||||
function getNodePerformanceData(onlyLast: boolean = false) {
|
const nodePerformanceData = $derived.by(() => {
|
||||||
let data = onlyLast ? getLasts() : getAverages();
|
const source = showAverage ? averages : lasts;
|
||||||
|
return Object.entries(source)
|
||||||
return Object.entries(data)
|
|
||||||
.filter(([key]) => key.startsWith("node/"))
|
.filter(([key]) => key.startsWith("node/"))
|
||||||
.sort((a, b) => b[1] - a[1]);
|
.sort((a, b) => b[1] - a[1]);
|
||||||
}
|
});
|
||||||
|
|
||||||
function getViewerPerformanceData(onlyLast: boolean = false) {
|
const viewerPerformanceData = $derived.by(() => {
|
||||||
let data = onlyLast ? getLasts() : getAverages();
|
const source = showAverage ? averages : lasts;
|
||||||
return Object.entries(data)
|
return Object.entries(source)
|
||||||
.filter(
|
.filter(
|
||||||
([key]) =>
|
([key]) =>
|
||||||
key !== "total-vertices" &&
|
key !== "total-vertices" &&
|
||||||
@@ -110,14 +112,29 @@
|
|||||||
viewerKeys.includes(key),
|
viewerKeys.includes(key),
|
||||||
)
|
)
|
||||||
.sort((a, b) => b[1] - a[1]);
|
.sort((a, b) => b[1] - a[1]);
|
||||||
}
|
});
|
||||||
|
|
||||||
function getTotalPoints() {
|
const splitValues = $derived.by(() => {
|
||||||
|
if (showAverage) {
|
||||||
|
return [
|
||||||
|
getAverage("worker-transfer"),
|
||||||
|
getAverage("runtime"),
|
||||||
|
getAverage("update-geometries"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
getLast("worker-transfer"),
|
||||||
|
getLast("runtime"),
|
||||||
|
getLast("update-geometries"),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
const totalPoints = $derived.by(() => {
|
||||||
if (showAverage) {
|
if (showAverage) {
|
||||||
return data.map((run) => {
|
return data.map((run) => {
|
||||||
return (
|
return (
|
||||||
run["runtime"].reduce((acc, v) => acc + v, 0) +
|
(run["runtime"]?.reduce((acc, v) => acc + v, 0) || 0) +
|
||||||
run["update-geometries"].reduce((acc, v) => acc + v, 0) +
|
(run["update-geometries"]?.reduce((acc, v) => acc + v, 0) || 0) +
|
||||||
(run["worker-transfer"]?.reduce((acc, v) => acc + v, 0) || 0)
|
(run["worker-transfer"]?.reduce((acc, v) => acc + v, 0) || 0)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -125,16 +142,16 @@
|
|||||||
|
|
||||||
return data.map((run) => {
|
return data.map((run) => {
|
||||||
return (
|
return (
|
||||||
run["runtime"][0] +
|
(run["runtime"]?.[0] || 0) +
|
||||||
run["update-geometries"][0] +
|
(run["update-geometries"]?.[0] || 0) +
|
||||||
(run["worker-transfer"]?.[0] || 0)
|
(run["worker-transfer"]?.[0] || 0)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
function constructPoints(key: string) {
|
function constructPoints(key: string) {
|
||||||
if (key === "total") {
|
if (key === "total") {
|
||||||
return getTotalPoints();
|
return totalPoints;
|
||||||
}
|
}
|
||||||
return data.map((run) => {
|
return data.map((run) => {
|
||||||
if (key in run) {
|
if (key in run) {
|
||||||
@@ -148,47 +165,33 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSplitValues(): number[] {
|
const computedTotalDisplay = $derived.by(() =>
|
||||||
if (showAverage) {
|
round(showAverage ? totalPerformance.average : totalPerformance.onlyLast),
|
||||||
return [
|
);
|
||||||
getAverage("worker-transfer"),
|
|
||||||
getAverage("runtime"),
|
|
||||||
getAverage("update-geometries"),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
const computedFps = $derived.by(() =>
|
||||||
getLast("worker-transfer"),
|
Math.floor(
|
||||||
getLast("runtime"),
|
1000 /
|
||||||
getLast("update-geometries"),
|
(showAverage
|
||||||
];
|
? totalPerformance.average || 1
|
||||||
}
|
: totalPerformance.onlyLast || 1),
|
||||||
|
),
|
||||||
function getTitle(t: string) {
|
);
|
||||||
if (t.includes("/")) {
|
|
||||||
return `Node ${t.split("/").slice(-1).join("/")}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return t
|
|
||||||
.split("-")
|
|
||||||
.map((v) => v[0].toUpperCase() + v.slice(1))
|
|
||||||
.join(" ");
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#key $activeType && data}
|
{#if data.length !== 0}
|
||||||
{#if $activeType === "cache-hit"}
|
{#if activeType === "cache-hit"}
|
||||||
<Monitor
|
<Monitor
|
||||||
title="Cache Hits"
|
title="Cache Hits"
|
||||||
points={constructPoints($activeType)}
|
points={constructPoints(activeType)}
|
||||||
min={0}
|
min={0}
|
||||||
max={1}
|
max={1}
|
||||||
type="%"
|
type="%"
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<Monitor
|
<Monitor
|
||||||
title={getTitle($activeType)}
|
title={getTitle(activeType)}
|
||||||
points={constructPoints($activeType)}
|
points={constructPoints(activeType)}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -198,116 +201,108 @@
|
|||||||
<label for="show-total">Show Average</label>
|
<label for="show-total">Show Average</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if data.length !== 0}
|
<BarSplit
|
||||||
<BarSplit
|
labels={["worker-transfer", "runtime", "update-geometries"]}
|
||||||
labels={["worker-transfer", "runtime", "update-geometries"]}
|
values={splitValues}
|
||||||
values={getSplitValues()}
|
/>
|
||||||
/>
|
|
||||||
|
|
||||||
<h3>General</h3>
|
<h3>General</h3>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{computedTotalDisplay}<span>ms</span>
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
class:active={activeType === "total"}
|
||||||
|
onclick={() => (activeType = "total")}
|
||||||
|
>
|
||||||
|
total<span>({computedFps}fps)</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{#each performanceData as [key, value]}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>{round(value)}<span>ms</span></td>
|
||||||
{round(getTotalPerformance(!showAverage))}<span>ms</span>
|
|
||||||
</td>
|
|
||||||
<td
|
<td
|
||||||
class:active={$activeType === "total"}
|
class:active={activeType === key}
|
||||||
on:click={() => ($activeType = "total")}
|
onclick={() => (activeType = key)}
|
||||||
>
|
>
|
||||||
total<span
|
{key}
|
||||||
>({Math.floor(
|
|
||||||
1000 / getTotalPerformance(showAverage),
|
|
||||||
)}fps)</span
|
|
||||||
>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{#each getPerformanceData(!showAverage) as [key, value]}
|
{/each}
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
{round(value)}<span>ms</span>
|
|
||||||
</td>
|
|
||||||
<td
|
|
||||||
class:active={$activeType === key}
|
|
||||||
on:click={() => ($activeType = key)}
|
|
||||||
>
|
|
||||||
{key}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/each}
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>{data.length}</td>
|
||||||
|
<td>Samples</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr><td><h3>Nodes</h3></td></tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td
|
||||||
|
>{showAverage ? cacheRatio.average : cacheRatio.onlyLast}<span
|
||||||
|
>%</span
|
||||||
|
></td
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
class:active={activeType === "cache-hit"}
|
||||||
|
onclick={() => (activeType = "cache-hit")}
|
||||||
|
>
|
||||||
|
cache hits
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{#each nodePerformanceData as [key, value]}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{data.length}</td>
|
<td>{round(value)}<span>ms</span></td>
|
||||||
<td>Samples</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<h3>Nodes</h3>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td> {getCacheRatio(!showAverage)}<span>%</span> </td>
|
|
||||||
<td
|
<td
|
||||||
class:active={$activeType === "cache-hit"}
|
class:active={activeType === key}
|
||||||
on:click={() => ($activeType = "cache-hit")}>cache hits</td
|
onclick={() => (activeType = key)}
|
||||||
>
|
>
|
||||||
</tr>
|
{key.split("/").slice(-1).join("/")}
|
||||||
{#each getNodePerformanceData(!showAverage) as [key, value]}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
{round(value)}<span>ms</span>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td
|
|
||||||
class:active={$activeType === key}
|
|
||||||
on:click={() => ($activeType = key)}
|
|
||||||
>
|
|
||||||
{key.split("/").slice(-1).join("/")}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/each}
|
|
||||||
</tbody>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<h3>Viewer</h3>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
{/each}
|
||||||
<tbody>
|
</tbody>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr><td><h3>Viewer</h3></td></tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>{humanizeNumber(getLast("total-vertices"))}</td>
|
||||||
|
<td>Vertices</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{humanizeNumber(getLast("total-faces"))}</td>
|
||||||
|
<td>Faces</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{#each viewerPerformanceData as [key, value]}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{humanizeNumber(getLast("total-vertices"))}</td>
|
<td>{round(value)}<span>ms</span></td>
|
||||||
<td>Vertices</td>
|
<td
|
||||||
|
class:active={activeType === key}
|
||||||
|
onclick={() => (activeType = key)}
|
||||||
|
>
|
||||||
|
{key.split("/").slice(-1).join("/")}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
{/each}
|
||||||
<td>{humanizeNumber(getLast("total-faces"))}</td>
|
</tbody>
|
||||||
<td>Faces</td>
|
</table>
|
||||||
</tr>
|
|
||||||
{#each getViewerPerformanceData(!showAverage) as [key, value]}
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
{round(value)}<span>ms</span>
|
|
||||||
</td>
|
|
||||||
<td
|
|
||||||
class:active={$activeType === key}
|
|
||||||
on:click={() => ($activeType = key)}
|
|
||||||
>
|
|
||||||
{key.split("/").slice(-1).join("/")}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{/each}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{:else}
|
|
||||||
<p>No runs available</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{/key}
|
{:else}
|
||||||
|
<p>No runs available</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
h3 {
|
h3 {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let points: number[];
|
const { points }: { points: number[] } = $props();
|
||||||
|
|
||||||
function constructPath() {
|
const path = $derived.by(() => {
|
||||||
const max = Math.max(...points);
|
const max = Math.max(...points);
|
||||||
const min = Math.min(...points);
|
const min = Math.min(...points);
|
||||||
return points
|
return points
|
||||||
@@ -11,13 +11,11 @@
|
|||||||
return `${x},${y}`;
|
return `${x},${y}`;
|
||||||
})
|
})
|
||||||
.join(" ");
|
.join(" ");
|
||||||
}
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svg preserveAspectRatio="none" viewBox="0 0 100 100">
|
<svg preserveAspectRatio="none" viewBox="0 0 100 100">
|
||||||
{#key points}
|
<polyline vector-effect="non-scaling-stroke" points={path} />
|
||||||
<polyline vector-effect="non-scaling-stroke" points={constructPath()} />
|
|
||||||
{/key}
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -35,6 +35,9 @@
|
|||||||
scene = $bindable(),
|
scene = $bindable(),
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
|
let geometries = $state.raw<BufferGeometry[]>([]);
|
||||||
|
let center = $state(new Vector3(0, 4, 0));
|
||||||
|
|
||||||
useTask(
|
useTask(
|
||||||
(delta) => {
|
(delta) => {
|
||||||
fps.push(1 / delta);
|
fps.push(1 / delta);
|
||||||
@@ -45,11 +48,13 @@
|
|||||||
|
|
||||||
export const invalidate = function () {
|
export const invalidate = function () {
|
||||||
if (scene) {
|
if (scene) {
|
||||||
geometries = scene.children
|
const geos: BufferGeometry[] = [];
|
||||||
.filter((child) => "geometry" in child && child.isObject3D)
|
scene.traverse(function (child) {
|
||||||
.map((child) => {
|
if (isMesh(child)) {
|
||||||
return (child as Mesh).geometry;
|
geos.push(child.geometry);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
geometries = geos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geometries && scene && centerCamera) {
|
if (geometries && scene && centerCamera) {
|
||||||
@@ -62,9 +67,6 @@
|
|||||||
_invalidate();
|
_invalidate();
|
||||||
};
|
};
|
||||||
|
|
||||||
let geometries = $state<BufferGeometry[]>();
|
|
||||||
let center = $state(new Vector3(0, 4, 0));
|
|
||||||
|
|
||||||
function isMesh(child: Mesh | any): child is Mesh {
|
function isMesh(child: Mesh | any): child is Mesh {
|
||||||
return child.isObject3D && "material" in child;
|
return child.isObject3D && "material" in child;
|
||||||
}
|
}
|
||||||
@@ -76,7 +78,7 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
const wireframe = appSettings.value.debug.wireframe;
|
const wireframe = appSettings.value.debug.wireframe;
|
||||||
scene.traverse(function (child) {
|
scene.traverse(function (child) {
|
||||||
if (isMesh(child) && isMatCapMaterial(child.material)) {
|
if (isMesh(child) && isMatCapMaterial(child.material) && child.visible) {
|
||||||
child.material.wireframe = wireframe;
|
child.material.wireframe = wireframe;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -90,6 +92,13 @@
|
|||||||
geo.attributes.position.array[i + 2],
|
geo.attributes.position.array[i + 2],
|
||||||
] as Vector3Tuple;
|
] as Vector3Tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $effect(() => {
|
||||||
|
// console.log({
|
||||||
|
// geometries: $state.snapshot(geometries),
|
||||||
|
// indices: appSettings.value.debug.showIndices,
|
||||||
|
// });
|
||||||
|
// });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Camera {center} {centerCamera} />
|
<Camera {center} {centerCamera} />
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export const AppSettingTypes = {
|
|||||||
},
|
},
|
||||||
useWorker: {
|
useWorker: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
label: "Execute runtime in worker",
|
label: "Execute in WebWorker",
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
showIndices: {
|
showIndices: {
|
||||||
|
|||||||
Reference in New Issue
Block a user