温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/perf_hooks/timerify
点击访问原文链接

Node perf_hooks.timerify function | API Reference | Bun

Node perf_hooks.timerify function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:perf_hooks/timerifyFtimerify

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:perf_hooks/timerifyFtimerify

function

perf_hooks.timerify { console.log(list.getEntries()[0].duration); performance.clearMarks(); performance.clearMeasures(); obs.disconnect(); }); obs.observe({ entryTypes: ['function'] }); // A performance timeline entry will be created wrapped(); ``` If the wrapped function returns a promise, a finally handler will be attached to the promise and the duration will be reported once the finally handler is invoked." data-algolia-static="false" data-algolia-merged="false" data-type="Function">function timerifyT extends (...args: any[]) => any>(fn: T,options?: TimerifyOptions): T;

This property is an extension by Node.js. It is not available in Web browsers.

Wraps a function within a new function that measures the running time of the wrapped function. A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.

import { timerify, performance, PerformanceObserver } from 'node:perf_hooks';

function someFunction() {
console.log('hello world');
}

const wrapped = timerify(someFunction);

const obs = new PerformanceObserver((list) => {
console.log(list.getEntries()[0].duration);

performance.clearMarks();
performance.clearMeasures();
obs.disconnect();
});
obs.observe({ entryTypes: ['function'] });

// A performance timeline entry will be created
wrapped();

If the wrapped function returns a promise, a finally handler will be attached to the promise and the duration will be reported once the finally handler is invoked.

Referenced typesinterface TimerifyOptionshistogram?: RecordableHistogram

A histogram object created using perf_hooks.createHistogram() that will record runtime durations in nanoseconds.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node perf_hooks.timerify function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:perf_hooks.timerify | Bun