/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/sync/src/performance.ts
35 строк
947 B
Alec Geatches
RTC: Remove excess autosave notices (when not useful) (#80539)
31 июл 2026, 18:44
Не верифицирован
31 июл 2026, 18:44
cf6b796
Код
Авторство
О чём код?
/** * Wraps a function and logs the time it takes to execute. * * @param fn - The function to be wrapped. */ export function logPerformanceTiming< Params extends Array< unknown >, ReturnType = void, >( fn: ( ...args: Params ) => ReturnType ): typeof fn { return function ( this: unknown, ...args: Params ): ReturnType { const start = performance.now(); const result = fn.apply( this, args ); const end = performance.now(); // eslint-disable-next-line no-console console.log( `[SyncManager][performance]: ${ fn.name } took ${ ( end - start ).toFixed( 2 ) } ms` ); return result; }; } /** * A pass-through function that invokes the provided function with its arguments * without moidyfing its type. * * @param fn - The function to be invoked. */ export function passThru< T extends ( ...args: any[] ) => any >( fn: T ): T { return ( ( ...args: Parameters< T > ): ReturnType< T > => fn( ...args ) ) as T; }