export class ServerTiming {
    headers;
    constructor() {
        this.headers = [];
    }
    getHeader() {
        return this.headers.join(',');
    }
    async time(name, description, promise) {
        const startTime = performance.now();
        try {
            return await promise; // Execute the function
        }
        finally {
            const endTime = performance.now();
            const duration = endTime - startTime;
            this.add(name, description, duration);
        }
    }
    add(name, description, ms) {
        this.headers.push(`${name};dur=${Math.round(ms)}${description === '' ? '' : `;desc="${description}"`}`);
    }
}
//# sourceMappingURL=server-timing.js.map