engine
engine copied to clipboard
fix: return measured result
A minor change to cross-performance.
returns the result a measurement. updated the d.ts file accordingly
this is a none breaking change since the original return type was void.
would be useful in the following situation
import performance from '@wixc3/cross-performance';
export const measure = async <T extends (...args: any[]) => any>(label: string, method: T) => {
const startLabel = `startMeasure: ${label}`;
const endLabel = `endMeasure: ${label}`;
performance.mark(startLabel);
const result = await method();
performance.mark(endLabel);
return {
result,
measurement: performance.measure(label, startLabel, endLabel),
};
};
const {
result,
measurement: { name, duration },
} = await measure(label, method);