export class GPUProfiler {
    supported;
    unavailableReason;
    samples = [];
    constructor(supported = false, unavailableReason = "GPU timing extension unavailable") {
        this.supported = supported;
        this.unavailableReason = unavailableReason;
    }
    begin(label) {
        const trimmed = label.trim();
        if (trimmed.length === 0) {
            throw new Error("GPU profiler sample label is required");
        }
        const start = performance.now();
        return {
            end: (durationMs = performance.now() - start) => {
                const sample = { label: trimmed, durationMs };
                this.samples.push(sample);
                return sample;
            }
        };
    }
    snapshot() {
        return {
            supported: this.supported,
            sampleCount: this.samples.length,
            samples: [...this.samples],
            ...(this.supported ? {} : { unavailableReason: this.unavailableReason })
        };
    }
}
//# sourceMappingURL=GPUProfiler.js.map