Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion apps/benchmarks/doctor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
"enabled": false
},
"ignore": {
"files": ["vitexec/**", "src/benchmark/bake-host-baseline.ts", "src/benchmark/worker-queue-evidence.ts"],
"files": [
"vitexec/**",
"src/benchmark/bake-host-baseline.ts",
"src/benchmark/worker-queue-evidence.ts",
"src/benchmark/targets/measurement/comparison-preview.ts"
],
"overrides": [
{
"files": ["src/benchmark/paragraph-layout-digest.ts"],
Expand Down
4 changes: 2 additions & 2 deletions apps/benchmarks/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import type {
ComparisonWorkloadId,
ComparisonWorkloadPersistentScene,
ComparisonWorkloadStats,
} from './renderer/comparison-workload';
} from './workloads/comparison/scene';
import {
benchmarkWorkloadDefinition,
comparisonWorkloadId,
Expand All @@ -108,7 +108,7 @@ let comparisonWorkloadModule: ReturnType<typeof importComparisonWorkload> | unde
const liveSceneAssetResources = new Map<string, Promise<void>>();

function importComparisonWorkload() {
return import('./renderer/comparison-workload');
return import('./workloads/comparison/scene');
}

function loadBenchmarkFontAssets() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {
createComparisonWorkloadPersistentScene,
type ComparisonWorkloadConfiguration,
type ComparisonWorkloadId,
type ComparisonWorkloadPersistentSceneOptions,
type ComparisonWorkloadStats,
} from '../../../workloads/comparison/scene';
import { createPersistentRenderHost } from '../../../renderer/persistent-render-host';

/**
* Measurement-only adapter for probes that need an isolated canvas. The retained
* workload scene remains renderer-agnostic; this adapter owns the host lifecycle.
*/
export interface ComparisonWorkloadPreview {
dispose(): Promise<void>;
panBy(deltaX: number, deltaY: number): { readonly deltaX: number; readonly deltaY: number } | void;
resetView(): void;
resize(width: number, height: number): void;
update(configuration: ComparisonWorkloadConfiguration): Promise<void>;
zoomBy(factor: number): void;
}

export interface ComparisonWorkloadPreviewOptions extends ComparisonWorkloadPersistentSceneOptions {
readonly canvas: HTMLCanvasElement;
readonly dpr: number;
readonly height: number;
readonly signal?: AbortSignal;
readonly width: number;
}

export type { ComparisonWorkloadConfiguration, ComparisonWorkloadId, ComparisonWorkloadStats };

export async function createComparisonWorkloadPreview(
options: ComparisonWorkloadPreviewOptions,
): Promise<ComparisonWorkloadPreview> {
const { canvas, dpr, height, signal, width, ...sceneOptions } = options;
const host = await createPersistentRenderHost({
backend: options.backend,
canvas,
dpr,
height,
onError: options.onError,
width,
});
const scene = createComparisonWorkloadPersistentScene(sceneOptions);
try {
const lease = await host.replaceScene(scene, signal);
let disposal: Promise<void> | undefined;
return {
panBy(deltaX, deltaY) {
return scene.panBy(deltaX, deltaY);
},
resetView() {
scene.resetView();
},
resize(nextWidth, nextHeight) {
host.resize(nextWidth, nextHeight);
},
update(configuration) {
return scene.update(configuration);
},
zoomBy(factor) {
scene.zoomBy(factor);
},
dispose() {
disposal ??= (async () => {
try {
await lease.release();
} finally {
await host.dispose();
}
})();
return disposal;
},
};
} catch (error) {
await host.dispose();
throw error;
}
}
2 changes: 1 addition & 1 deletion apps/benchmarks/src/components/workload-rail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { TechniqueSwitcher } from './technique-switcher';
let comparisonWorkloadModule: ReturnType<typeof importComparisonWorkload> | undefined;

function importComparisonWorkload() {
return import('../renderer/comparison-workload');
return import('../workloads/comparison/scene');
}

function preloadComparisonWorkload(): ReturnType<typeof importComparisonWorkload> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
zoomTextMaximumScale,
type ComparisonWorkloadConfiguration,
type IconGridAutoPanState,
} from './comparison-workload';
} from './scene';

const baseConfiguration: ComparisonWorkloadConfiguration = {
amount: 50,
Expand Down
Loading
Loading