11cb0ef41Sopenharmony_ci<!DOCTYPE html> 21cb0ef41Sopenharmony_ci<html lang="en"> 31cb0ef41Sopenharmony_ci<head> 41cb0ef41Sopenharmony_ci <meta charset="utf-8"> 51cb0ef41Sopenharmony_ci <meta name="viewport" content="width=device-width"> 61cb0ef41Sopenharmony_ci <meta name="nodejs.org:node-version" content="v18.20.1"> 71cb0ef41Sopenharmony_ci <title>Performance measurement APIs | Node.js v18.20.1 Documentation</title> 81cb0ef41Sopenharmony_ci <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic&display=fallback"> 91cb0ef41Sopenharmony_ci <link rel="stylesheet" href="assets/style.css"> 101cb0ef41Sopenharmony_ci <link rel="stylesheet" href="assets/hljs.css"> 111cb0ef41Sopenharmony_ci <link rel="canonical" href="https://nodejs.org/api/perf_hooks.html"> 121cb0ef41Sopenharmony_ci <script async defer src="assets/api.js" type="text/javascript"></script> 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ci</head> 151cb0ef41Sopenharmony_ci<body class="alt apidoc" id="api-section-perf_hooks"> 161cb0ef41Sopenharmony_ci <div id="content" class="clearfix"> 171cb0ef41Sopenharmony_ci <div id="column2" class="interior"> 181cb0ef41Sopenharmony_ci <div id="intro" class="interior"> 191cb0ef41Sopenharmony_ci <a href="/" title="Go back to the home page"> 201cb0ef41Sopenharmony_ci Node.js 211cb0ef41Sopenharmony_ci </a> 221cb0ef41Sopenharmony_ci </div> 231cb0ef41Sopenharmony_ci <ul> 241cb0ef41Sopenharmony_ci<li><a href="documentation.html" class="nav-documentation">About this documentation</a></li> 251cb0ef41Sopenharmony_ci<li><a href="synopsis.html" class="nav-synopsis">Usage and example</a></li> 261cb0ef41Sopenharmony_ci</ul> 271cb0ef41Sopenharmony_ci<hr class="line"> 281cb0ef41Sopenharmony_ci<ul> 291cb0ef41Sopenharmony_ci<li><a href="assert.html" class="nav-assert">Assertion testing</a></li> 301cb0ef41Sopenharmony_ci<li><a href="async_context.html" class="nav-async_context">Asynchronous context tracking</a></li> 311cb0ef41Sopenharmony_ci<li><a href="async_hooks.html" class="nav-async_hooks">Async hooks</a></li> 321cb0ef41Sopenharmony_ci<li><a href="buffer.html" class="nav-buffer">Buffer</a></li> 331cb0ef41Sopenharmony_ci<li><a href="addons.html" class="nav-addons">C++ addons</a></li> 341cb0ef41Sopenharmony_ci<li><a href="n-api.html" class="nav-n-api">C/C++ addons with Node-API</a></li> 351cb0ef41Sopenharmony_ci<li><a href="embedding.html" class="nav-embedding">C++ embedder API</a></li> 361cb0ef41Sopenharmony_ci<li><a href="child_process.html" class="nav-child_process">Child processes</a></li> 371cb0ef41Sopenharmony_ci<li><a href="cluster.html" class="nav-cluster">Cluster</a></li> 381cb0ef41Sopenharmony_ci<li><a href="cli.html" class="nav-cli">Command-line options</a></li> 391cb0ef41Sopenharmony_ci<li><a href="console.html" class="nav-console">Console</a></li> 401cb0ef41Sopenharmony_ci<li><a href="corepack.html" class="nav-corepack">Corepack</a></li> 411cb0ef41Sopenharmony_ci<li><a href="crypto.html" class="nav-crypto">Crypto</a></li> 421cb0ef41Sopenharmony_ci<li><a href="debugger.html" class="nav-debugger">Debugger</a></li> 431cb0ef41Sopenharmony_ci<li><a href="deprecations.html" class="nav-deprecations">Deprecated APIs</a></li> 441cb0ef41Sopenharmony_ci<li><a href="diagnostics_channel.html" class="nav-diagnostics_channel">Diagnostics Channel</a></li> 451cb0ef41Sopenharmony_ci<li><a href="dns.html" class="nav-dns">DNS</a></li> 461cb0ef41Sopenharmony_ci<li><a href="domain.html" class="nav-domain">Domain</a></li> 471cb0ef41Sopenharmony_ci<li><a href="errors.html" class="nav-errors">Errors</a></li> 481cb0ef41Sopenharmony_ci<li><a href="events.html" class="nav-events">Events</a></li> 491cb0ef41Sopenharmony_ci<li><a href="fs.html" class="nav-fs">File system</a></li> 501cb0ef41Sopenharmony_ci<li><a href="globals.html" class="nav-globals">Globals</a></li> 511cb0ef41Sopenharmony_ci<li><a href="http.html" class="nav-http">HTTP</a></li> 521cb0ef41Sopenharmony_ci<li><a href="http2.html" class="nav-http2">HTTP/2</a></li> 531cb0ef41Sopenharmony_ci<li><a href="https.html" class="nav-https">HTTPS</a></li> 541cb0ef41Sopenharmony_ci<li><a href="inspector.html" class="nav-inspector">Inspector</a></li> 551cb0ef41Sopenharmony_ci<li><a href="intl.html" class="nav-intl">Internationalization</a></li> 561cb0ef41Sopenharmony_ci<li><a href="modules.html" class="nav-modules">Modules: CommonJS modules</a></li> 571cb0ef41Sopenharmony_ci<li><a href="esm.html" class="nav-esm">Modules: ECMAScript modules</a></li> 581cb0ef41Sopenharmony_ci<li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li> 591cb0ef41Sopenharmony_ci<li><a href="packages.html" class="nav-packages">Modules: Packages</a></li> 601cb0ef41Sopenharmony_ci<li><a href="net.html" class="nav-net">Net</a></li> 611cb0ef41Sopenharmony_ci<li><a href="os.html" class="nav-os">OS</a></li> 621cb0ef41Sopenharmony_ci<li><a href="path.html" class="nav-path">Path</a></li> 631cb0ef41Sopenharmony_ci<li><a href="perf_hooks.html" class="nav-perf_hooks active">Performance hooks</a></li> 641cb0ef41Sopenharmony_ci<li><a href="permissions.html" class="nav-permissions">Permissions</a></li> 651cb0ef41Sopenharmony_ci<li><a href="process.html" class="nav-process">Process</a></li> 661cb0ef41Sopenharmony_ci<li><a href="punycode.html" class="nav-punycode">Punycode</a></li> 671cb0ef41Sopenharmony_ci<li><a href="querystring.html" class="nav-querystring">Query strings</a></li> 681cb0ef41Sopenharmony_ci<li><a href="readline.html" class="nav-readline">Readline</a></li> 691cb0ef41Sopenharmony_ci<li><a href="repl.html" class="nav-repl">REPL</a></li> 701cb0ef41Sopenharmony_ci<li><a href="report.html" class="nav-report">Report</a></li> 711cb0ef41Sopenharmony_ci<li><a href="single-executable-applications.html" class="nav-single-executable-applications">Single executable applications</a></li> 721cb0ef41Sopenharmony_ci<li><a href="stream.html" class="nav-stream">Stream</a></li> 731cb0ef41Sopenharmony_ci<li><a href="string_decoder.html" class="nav-string_decoder">String decoder</a></li> 741cb0ef41Sopenharmony_ci<li><a href="test.html" class="nav-test">Test runner</a></li> 751cb0ef41Sopenharmony_ci<li><a href="timers.html" class="nav-timers">Timers</a></li> 761cb0ef41Sopenharmony_ci<li><a href="tls.html" class="nav-tls">TLS/SSL</a></li> 771cb0ef41Sopenharmony_ci<li><a href="tracing.html" class="nav-tracing">Trace events</a></li> 781cb0ef41Sopenharmony_ci<li><a href="tty.html" class="nav-tty">TTY</a></li> 791cb0ef41Sopenharmony_ci<li><a href="dgram.html" class="nav-dgram">UDP/datagram</a></li> 801cb0ef41Sopenharmony_ci<li><a href="url.html" class="nav-url">URL</a></li> 811cb0ef41Sopenharmony_ci<li><a href="util.html" class="nav-util">Utilities</a></li> 821cb0ef41Sopenharmony_ci<li><a href="v8.html" class="nav-v8">V8</a></li> 831cb0ef41Sopenharmony_ci<li><a href="vm.html" class="nav-vm">VM</a></li> 841cb0ef41Sopenharmony_ci<li><a href="wasi.html" class="nav-wasi">WASI</a></li> 851cb0ef41Sopenharmony_ci<li><a href="webcrypto.html" class="nav-webcrypto">Web Crypto API</a></li> 861cb0ef41Sopenharmony_ci<li><a href="webstreams.html" class="nav-webstreams">Web Streams API</a></li> 871cb0ef41Sopenharmony_ci<li><a href="worker_threads.html" class="nav-worker_threads">Worker threads</a></li> 881cb0ef41Sopenharmony_ci<li><a href="zlib.html" class="nav-zlib">Zlib</a></li> 891cb0ef41Sopenharmony_ci</ul> 901cb0ef41Sopenharmony_ci<hr class="line"> 911cb0ef41Sopenharmony_ci<ul> 921cb0ef41Sopenharmony_ci<li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code repository and issue tracker</a></li> 931cb0ef41Sopenharmony_ci</ul> 941cb0ef41Sopenharmony_ci </div> 951cb0ef41Sopenharmony_ci 961cb0ef41Sopenharmony_ci <div id="column1" data-id="perf_hooks" class="interior"> 971cb0ef41Sopenharmony_ci <header class="header"> 981cb0ef41Sopenharmony_ci <div class="header-container"> 991cb0ef41Sopenharmony_ci <h1>Node.js v18.20.1 documentation</h1> 1001cb0ef41Sopenharmony_ci <button class="theme-toggle-btn" id="theme-toggle-btn" title="Toggle dark mode/light mode" aria-label="Toggle dark mode/light mode" hidden> 1011cb0ef41Sopenharmony_ci <svg xmlns="http://www.w3.org/2000/svg" class="icon dark-icon" height="24" width="24"> 1021cb0ef41Sopenharmony_ci <path fill="none" d="M0 0h24v24H0z" /> 1031cb0ef41Sopenharmony_ci <path d="M11.1 12.08c-2.33-4.51-.5-8.48.53-10.07C6.27 2.2 1.98 6.59 1.98 12c0 .14.02.28.02.42.62-.27 1.29-.42 2-.42 1.66 0 3.18.83 4.1 2.15A4.01 4.01 0 0111 18c0 1.52-.87 2.83-2.12 3.51.98.32 2.03.5 3.11.5 3.5 0 6.58-1.8 8.37-4.52-2.36.23-6.98-.97-9.26-5.41z"/> 1041cb0ef41Sopenharmony_ci <path d="M7 16h-.18C6.4 14.84 5.3 14 4 14c-1.66 0-3 1.34-3 3s1.34 3 3 3h3c1.1 0 2-.9 2-2s-.9-2-2-2z"/> 1051cb0ef41Sopenharmony_ci </svg> 1061cb0ef41Sopenharmony_ci <svg xmlns="http://www.w3.org/2000/svg" class="icon light-icon" height="24" width="24"> 1071cb0ef41Sopenharmony_ci <path d="M0 0h24v24H0z" fill="none" /> 1081cb0ef41Sopenharmony_ci <path d="M6.76 4.84l-1.8-1.79-1.41 1.41 1.79 1.79 1.42-1.41zM4 10.5H1v2h3v-2zm9-9.95h-2V3.5h2V.55zm7.45 3.91l-1.41-1.41-1.79 1.79 1.41 1.41 1.79-1.79zm-3.21 13.7l1.79 1.8 1.41-1.41-1.8-1.79-1.4 1.4zM20 10.5v2h3v-2h-3zm-8-5c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6-2.69-6-6-6zm-1 16.95h2V19.5h-2v2.95zm-7.45-3.91l1.41 1.41 1.79-1.8-1.41-1.41-1.79 1.8z"/> 1091cb0ef41Sopenharmony_ci </svg> 1101cb0ef41Sopenharmony_ci </button> 1111cb0ef41Sopenharmony_ci </div> 1121cb0ef41Sopenharmony_ci <div id="gtoc"> 1131cb0ef41Sopenharmony_ci <ul> 1141cb0ef41Sopenharmony_ci <li class="pinned-header">Node.js v18.20.1</li> 1151cb0ef41Sopenharmony_ci 1161cb0ef41Sopenharmony_ci <li class="picker-header"> 1171cb0ef41Sopenharmony_ci <a href="#"> 1181cb0ef41Sopenharmony_ci <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> 1191cb0ef41Sopenharmony_ci Table of contents 1201cb0ef41Sopenharmony_ci </a> 1211cb0ef41Sopenharmony_ci 1221cb0ef41Sopenharmony_ci <div class="picker"><div class="toc"><ul> 1231cb0ef41Sopenharmony_ci<li><span class="stability_2"><a href="#performance-measurement-apis">Performance measurement APIs</a></span> 1241cb0ef41Sopenharmony_ci<ul> 1251cb0ef41Sopenharmony_ci<li><a href="#perf_hooksperformance"><code>perf_hooks.performance</code></a> 1261cb0ef41Sopenharmony_ci<ul> 1271cb0ef41Sopenharmony_ci<li><a href="#performanceclearmarksname"><code>performance.clearMarks([name])</code></a></li> 1281cb0ef41Sopenharmony_ci<li><a href="#performanceclearmeasuresname"><code>performance.clearMeasures([name])</code></a></li> 1291cb0ef41Sopenharmony_ci<li><a href="#performanceclearresourcetimingsname"><code>performance.clearResourceTimings([name])</code></a></li> 1301cb0ef41Sopenharmony_ci<li><a href="#performanceeventlooputilizationutilization1-utilization2"><code>performance.eventLoopUtilization([utilization1[, utilization2]])</code></a></li> 1311cb0ef41Sopenharmony_ci<li><a href="#performancegetentries"><code>performance.getEntries()</code></a></li> 1321cb0ef41Sopenharmony_ci<li><a href="#performancegetentriesbynamename-type"><code>performance.getEntriesByName(name[, type])</code></a></li> 1331cb0ef41Sopenharmony_ci<li><a href="#performancegetentriesbytypetype"><code>performance.getEntriesByType(type)</code></a></li> 1341cb0ef41Sopenharmony_ci<li><a href="#performancemarkname-options"><code>performance.mark([name[, options]])</code></a></li> 1351cb0ef41Sopenharmony_ci<li><a href="#performancemarkresourcetimingtiminginfo-requestedurl-initiatortype-global-cachemode"><code>performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, global, cacheMode)</code></a></li> 1361cb0ef41Sopenharmony_ci<li><a href="#performancemeasurename-startmarkoroptions-endmark"><code>performance.measure(name[, startMarkOrOptions[, endMark]])</code></a></li> 1371cb0ef41Sopenharmony_ci<li><a href="#performancenodetiming"><code>performance.nodeTiming</code></a></li> 1381cb0ef41Sopenharmony_ci<li><a href="#performancenow"><code>performance.now()</code></a></li> 1391cb0ef41Sopenharmony_ci<li><a href="#performancesetresourcetimingbuffersizemaxsize"><code>performance.setResourceTimingBufferSize(maxSize)</code></a></li> 1401cb0ef41Sopenharmony_ci<li><a href="#performancetimeorigin"><code>performance.timeOrigin</code></a></li> 1411cb0ef41Sopenharmony_ci<li><a href="#performancetimerifyfn-options"><code>performance.timerify(fn[, options])</code></a></li> 1421cb0ef41Sopenharmony_ci<li><a href="#performancetojson"><code>performance.toJSON()</code></a> 1431cb0ef41Sopenharmony_ci<ul> 1441cb0ef41Sopenharmony_ci<li><a href="#event-resourcetimingbufferfull">Event: <code>'resourcetimingbufferfull'</code></a></li> 1451cb0ef41Sopenharmony_ci</ul> 1461cb0ef41Sopenharmony_ci</li> 1471cb0ef41Sopenharmony_ci</ul> 1481cb0ef41Sopenharmony_ci</li> 1491cb0ef41Sopenharmony_ci<li><a href="#class-performanceentry">Class: <code>PerformanceEntry</code></a> 1501cb0ef41Sopenharmony_ci<ul> 1511cb0ef41Sopenharmony_ci<li><a href="#performanceentrydetail"><code>performanceEntry.detail</code></a></li> 1521cb0ef41Sopenharmony_ci<li><a href="#performanceentryduration"><code>performanceEntry.duration</code></a></li> 1531cb0ef41Sopenharmony_ci<li><a href="#performanceentryentrytype"><code>performanceEntry.entryType</code></a></li> 1541cb0ef41Sopenharmony_ci<li><a href="#performanceentryflags"><code>performanceEntry.flags</code></a></li> 1551cb0ef41Sopenharmony_ci<li><a href="#performanceentryname"><code>performanceEntry.name</code></a></li> 1561cb0ef41Sopenharmony_ci<li><a href="#performanceentrykind"><code>performanceEntry.kind</code></a></li> 1571cb0ef41Sopenharmony_ci<li><a href="#performanceentrystarttime"><code>performanceEntry.startTime</code></a></li> 1581cb0ef41Sopenharmony_ci<li><a href="#garbage-collection-gc-details">Garbage Collection ('gc') Details</a></li> 1591cb0ef41Sopenharmony_ci<li><a href="#http-http-details">HTTP ('http') Details</a></li> 1601cb0ef41Sopenharmony_ci<li><a href="#http2-http2-details">HTTP/2 ('http2') Details</a></li> 1611cb0ef41Sopenharmony_ci<li><a href="#timerify-function-details">Timerify ('function') Details</a></li> 1621cb0ef41Sopenharmony_ci<li><a href="#net-net-details">Net ('net') Details</a></li> 1631cb0ef41Sopenharmony_ci<li><a href="#dns-dns-details">DNS ('dns') Details</a></li> 1641cb0ef41Sopenharmony_ci</ul> 1651cb0ef41Sopenharmony_ci</li> 1661cb0ef41Sopenharmony_ci<li><a href="#class-performancenodetiming">Class: <code>PerformanceNodeTiming</code></a> 1671cb0ef41Sopenharmony_ci<ul> 1681cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingbootstrapcomplete"><code>performanceNodeTiming.bootstrapComplete</code></a></li> 1691cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingenvironment"><code>performanceNodeTiming.environment</code></a></li> 1701cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingidletime"><code>performanceNodeTiming.idleTime</code></a></li> 1711cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingloopexit"><code>performanceNodeTiming.loopExit</code></a></li> 1721cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingloopstart"><code>performanceNodeTiming.loopStart</code></a></li> 1731cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingnodestart"><code>performanceNodeTiming.nodeStart</code></a></li> 1741cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingv8start"><code>performanceNodeTiming.v8Start</code></a></li> 1751cb0ef41Sopenharmony_ci</ul> 1761cb0ef41Sopenharmony_ci</li> 1771cb0ef41Sopenharmony_ci<li><a href="#class-performanceresourcetiming">Class: <code>PerformanceResourceTiming</code></a> 1781cb0ef41Sopenharmony_ci<ul> 1791cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingworkerstart"><code>performanceResourceTiming.workerStart</code></a></li> 1801cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingredirectstart"><code>performanceResourceTiming.redirectStart</code></a></li> 1811cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingredirectend"><code>performanceResourceTiming.redirectEnd</code></a></li> 1821cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingfetchstart"><code>performanceResourceTiming.fetchStart</code></a></li> 1831cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingdomainlookupstart"><code>performanceResourceTiming.domainLookupStart</code></a></li> 1841cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingdomainlookupend"><code>performanceResourceTiming.domainLookupEnd</code></a></li> 1851cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingconnectstart"><code>performanceResourceTiming.connectStart</code></a></li> 1861cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingconnectend"><code>performanceResourceTiming.connectEnd</code></a></li> 1871cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingsecureconnectionstart"><code>performanceResourceTiming.secureConnectionStart</code></a></li> 1881cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingrequeststart"><code>performanceResourceTiming.requestStart</code></a></li> 1891cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingresponseend"><code>performanceResourceTiming.responseEnd</code></a></li> 1901cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingtransfersize"><code>performanceResourceTiming.transferSize</code></a></li> 1911cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingencodedbodysize"><code>performanceResourceTiming.encodedBodySize</code></a></li> 1921cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingdecodedbodysize"><code>performanceResourceTiming.decodedBodySize</code></a></li> 1931cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingtojson"><code>performanceResourceTiming.toJSON()</code></a></li> 1941cb0ef41Sopenharmony_ci</ul> 1951cb0ef41Sopenharmony_ci</li> 1961cb0ef41Sopenharmony_ci<li><a href="#class-perf_hooksperformanceobserver">Class: <code>perf_hooks.PerformanceObserver</code></a> 1971cb0ef41Sopenharmony_ci<ul> 1981cb0ef41Sopenharmony_ci<li><a href="#performanceobserversupportedentrytypes"><code>PerformanceObserver.supportedEntryTypes</code></a></li> 1991cb0ef41Sopenharmony_ci<li><a href="#new-performanceobservercallback"><code>new PerformanceObserver(callback)</code></a></li> 2001cb0ef41Sopenharmony_ci<li><a href="#performanceobserverdisconnect"><code>performanceObserver.disconnect()</code></a></li> 2011cb0ef41Sopenharmony_ci<li><a href="#performanceobserverobserveoptions"><code>performanceObserver.observe(options)</code></a></li> 2021cb0ef41Sopenharmony_ci</ul> 2031cb0ef41Sopenharmony_ci</li> 2041cb0ef41Sopenharmony_ci<li><a href="#class-performanceobserverentrylist">Class: <code>PerformanceObserverEntryList</code></a> 2051cb0ef41Sopenharmony_ci<ul> 2061cb0ef41Sopenharmony_ci<li><a href="#performanceobserverentrylistgetentries"><code>performanceObserverEntryList.getEntries()</code></a></li> 2071cb0ef41Sopenharmony_ci<li><a href="#performanceobserverentrylistgetentriesbynamename-type"><code>performanceObserverEntryList.getEntriesByName(name[, type])</code></a></li> 2081cb0ef41Sopenharmony_ci<li><a href="#performanceobserverentrylistgetentriesbytypetype"><code>performanceObserverEntryList.getEntriesByType(type)</code></a></li> 2091cb0ef41Sopenharmony_ci</ul> 2101cb0ef41Sopenharmony_ci</li> 2111cb0ef41Sopenharmony_ci<li><a href="#perf_hookscreatehistogramoptions"><code>perf_hooks.createHistogram([options])</code></a></li> 2121cb0ef41Sopenharmony_ci<li><a href="#perf_hooksmonitoreventloopdelayoptions"><code>perf_hooks.monitorEventLoopDelay([options])</code></a></li> 2131cb0ef41Sopenharmony_ci<li><a href="#class-histogram">Class: <code>Histogram</code></a> 2141cb0ef41Sopenharmony_ci<ul> 2151cb0ef41Sopenharmony_ci<li><a href="#histogramcount"><code>histogram.count</code></a></li> 2161cb0ef41Sopenharmony_ci<li><a href="#histogramcountbigint"><code>histogram.countBigInt</code></a></li> 2171cb0ef41Sopenharmony_ci<li><a href="#histogramexceeds"><code>histogram.exceeds</code></a></li> 2181cb0ef41Sopenharmony_ci<li><a href="#histogramexceedsbigint"><code>histogram.exceedsBigInt</code></a></li> 2191cb0ef41Sopenharmony_ci<li><a href="#histogrammax"><code>histogram.max</code></a></li> 2201cb0ef41Sopenharmony_ci<li><a href="#histogrammaxbigint"><code>histogram.maxBigInt</code></a></li> 2211cb0ef41Sopenharmony_ci<li><a href="#histogrammean"><code>histogram.mean</code></a></li> 2221cb0ef41Sopenharmony_ci<li><a href="#histogrammin"><code>histogram.min</code></a></li> 2231cb0ef41Sopenharmony_ci<li><a href="#histogramminbigint"><code>histogram.minBigInt</code></a></li> 2241cb0ef41Sopenharmony_ci<li><a href="#histogrampercentilepercentile"><code>histogram.percentile(percentile)</code></a></li> 2251cb0ef41Sopenharmony_ci<li><a href="#histogrampercentilebigintpercentile"><code>histogram.percentileBigInt(percentile)</code></a></li> 2261cb0ef41Sopenharmony_ci<li><a href="#histogrampercentiles"><code>histogram.percentiles</code></a></li> 2271cb0ef41Sopenharmony_ci<li><a href="#histogrampercentilesbigint"><code>histogram.percentilesBigInt</code></a></li> 2281cb0ef41Sopenharmony_ci<li><a href="#histogramreset"><code>histogram.reset()</code></a></li> 2291cb0ef41Sopenharmony_ci<li><a href="#histogramstddev"><code>histogram.stddev</code></a></li> 2301cb0ef41Sopenharmony_ci</ul> 2311cb0ef41Sopenharmony_ci</li> 2321cb0ef41Sopenharmony_ci<li><a href="#class-intervalhistogram-extends-histogram">Class: <code>IntervalHistogram extends Histogram</code></a> 2331cb0ef41Sopenharmony_ci<ul> 2341cb0ef41Sopenharmony_ci<li><a href="#histogramdisable"><code>histogram.disable()</code></a></li> 2351cb0ef41Sopenharmony_ci<li><a href="#histogramenable"><code>histogram.enable()</code></a></li> 2361cb0ef41Sopenharmony_ci<li><a href="#cloning-an-intervalhistogram">Cloning an <code>IntervalHistogram</code></a></li> 2371cb0ef41Sopenharmony_ci</ul> 2381cb0ef41Sopenharmony_ci</li> 2391cb0ef41Sopenharmony_ci<li><a href="#class-recordablehistogram-extends-histogram">Class: <code>RecordableHistogram extends Histogram</code></a> 2401cb0ef41Sopenharmony_ci<ul> 2411cb0ef41Sopenharmony_ci<li><a href="#histogramaddother"><code>histogram.add(other)</code></a></li> 2421cb0ef41Sopenharmony_ci<li><a href="#histogramrecordval"><code>histogram.record(val)</code></a></li> 2431cb0ef41Sopenharmony_ci<li><a href="#histogramrecorddelta"><code>histogram.recordDelta()</code></a></li> 2441cb0ef41Sopenharmony_ci</ul> 2451cb0ef41Sopenharmony_ci</li> 2461cb0ef41Sopenharmony_ci<li><a href="#examples">Examples</a> 2471cb0ef41Sopenharmony_ci<ul> 2481cb0ef41Sopenharmony_ci<li><a href="#measuring-the-duration-of-async-operations">Measuring the duration of async operations</a></li> 2491cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-it-takes-to-load-dependencies">Measuring how long it takes to load dependencies</a></li> 2501cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-one-http-round-trip-takes">Measuring how long one HTTP round-trip takes</a></li> 2511cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-the-netconnect-only-for-tcp-takes-when-the-connection-is-successful">Measuring how long the <code>net.connect</code> (only for TCP) takes when the connection is successful</a></li> 2521cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-the-dns-takes-when-the-request-is-successful">Measuring how long the DNS takes when the request is successful</a></li> 2531cb0ef41Sopenharmony_ci</ul> 2541cb0ef41Sopenharmony_ci</li> 2551cb0ef41Sopenharmony_ci</ul> 2561cb0ef41Sopenharmony_ci</li> 2571cb0ef41Sopenharmony_ci</ul></div></div> 2581cb0ef41Sopenharmony_ci </li> 2591cb0ef41Sopenharmony_ci 2601cb0ef41Sopenharmony_ci 2611cb0ef41Sopenharmony_ci <li class="picker-header"> 2621cb0ef41Sopenharmony_ci <a href="#"> 2631cb0ef41Sopenharmony_ci <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> 2641cb0ef41Sopenharmony_ci Index 2651cb0ef41Sopenharmony_ci </a> 2661cb0ef41Sopenharmony_ci 2671cb0ef41Sopenharmony_ci <div class="picker"><ul> 2681cb0ef41Sopenharmony_ci<li><a href="documentation.html" class="nav-documentation">About this documentation</a></li> 2691cb0ef41Sopenharmony_ci<li><a href="synopsis.html" class="nav-synopsis">Usage and example</a></li> 2701cb0ef41Sopenharmony_ci 2711cb0ef41Sopenharmony_ci <li> 2721cb0ef41Sopenharmony_ci <a href="index.html">Index</a> 2731cb0ef41Sopenharmony_ci </li> 2741cb0ef41Sopenharmony_ci </ul> 2751cb0ef41Sopenharmony_ci 2761cb0ef41Sopenharmony_ci<hr class="line"> 2771cb0ef41Sopenharmony_ci<ul> 2781cb0ef41Sopenharmony_ci<li><a href="assert.html" class="nav-assert">Assertion testing</a></li> 2791cb0ef41Sopenharmony_ci<li><a href="async_context.html" class="nav-async_context">Asynchronous context tracking</a></li> 2801cb0ef41Sopenharmony_ci<li><a href="async_hooks.html" class="nav-async_hooks">Async hooks</a></li> 2811cb0ef41Sopenharmony_ci<li><a href="buffer.html" class="nav-buffer">Buffer</a></li> 2821cb0ef41Sopenharmony_ci<li><a href="addons.html" class="nav-addons">C++ addons</a></li> 2831cb0ef41Sopenharmony_ci<li><a href="n-api.html" class="nav-n-api">C/C++ addons with Node-API</a></li> 2841cb0ef41Sopenharmony_ci<li><a href="embedding.html" class="nav-embedding">C++ embedder API</a></li> 2851cb0ef41Sopenharmony_ci<li><a href="child_process.html" class="nav-child_process">Child processes</a></li> 2861cb0ef41Sopenharmony_ci<li><a href="cluster.html" class="nav-cluster">Cluster</a></li> 2871cb0ef41Sopenharmony_ci<li><a href="cli.html" class="nav-cli">Command-line options</a></li> 2881cb0ef41Sopenharmony_ci<li><a href="console.html" class="nav-console">Console</a></li> 2891cb0ef41Sopenharmony_ci<li><a href="corepack.html" class="nav-corepack">Corepack</a></li> 2901cb0ef41Sopenharmony_ci<li><a href="crypto.html" class="nav-crypto">Crypto</a></li> 2911cb0ef41Sopenharmony_ci<li><a href="debugger.html" class="nav-debugger">Debugger</a></li> 2921cb0ef41Sopenharmony_ci<li><a href="deprecations.html" class="nav-deprecations">Deprecated APIs</a></li> 2931cb0ef41Sopenharmony_ci<li><a href="diagnostics_channel.html" class="nav-diagnostics_channel">Diagnostics Channel</a></li> 2941cb0ef41Sopenharmony_ci<li><a href="dns.html" class="nav-dns">DNS</a></li> 2951cb0ef41Sopenharmony_ci<li><a href="domain.html" class="nav-domain">Domain</a></li> 2961cb0ef41Sopenharmony_ci<li><a href="errors.html" class="nav-errors">Errors</a></li> 2971cb0ef41Sopenharmony_ci<li><a href="events.html" class="nav-events">Events</a></li> 2981cb0ef41Sopenharmony_ci<li><a href="fs.html" class="nav-fs">File system</a></li> 2991cb0ef41Sopenharmony_ci<li><a href="globals.html" class="nav-globals">Globals</a></li> 3001cb0ef41Sopenharmony_ci<li><a href="http.html" class="nav-http">HTTP</a></li> 3011cb0ef41Sopenharmony_ci<li><a href="http2.html" class="nav-http2">HTTP/2</a></li> 3021cb0ef41Sopenharmony_ci<li><a href="https.html" class="nav-https">HTTPS</a></li> 3031cb0ef41Sopenharmony_ci<li><a href="inspector.html" class="nav-inspector">Inspector</a></li> 3041cb0ef41Sopenharmony_ci<li><a href="intl.html" class="nav-intl">Internationalization</a></li> 3051cb0ef41Sopenharmony_ci<li><a href="modules.html" class="nav-modules">Modules: CommonJS modules</a></li> 3061cb0ef41Sopenharmony_ci<li><a href="esm.html" class="nav-esm">Modules: ECMAScript modules</a></li> 3071cb0ef41Sopenharmony_ci<li><a href="module.html" class="nav-module">Modules: <code>node:module</code> API</a></li> 3081cb0ef41Sopenharmony_ci<li><a href="packages.html" class="nav-packages">Modules: Packages</a></li> 3091cb0ef41Sopenharmony_ci<li><a href="net.html" class="nav-net">Net</a></li> 3101cb0ef41Sopenharmony_ci<li><a href="os.html" class="nav-os">OS</a></li> 3111cb0ef41Sopenharmony_ci<li><a href="path.html" class="nav-path">Path</a></li> 3121cb0ef41Sopenharmony_ci<li><a href="perf_hooks.html" class="nav-perf_hooks active">Performance hooks</a></li> 3131cb0ef41Sopenharmony_ci<li><a href="permissions.html" class="nav-permissions">Permissions</a></li> 3141cb0ef41Sopenharmony_ci<li><a href="process.html" class="nav-process">Process</a></li> 3151cb0ef41Sopenharmony_ci<li><a href="punycode.html" class="nav-punycode">Punycode</a></li> 3161cb0ef41Sopenharmony_ci<li><a href="querystring.html" class="nav-querystring">Query strings</a></li> 3171cb0ef41Sopenharmony_ci<li><a href="readline.html" class="nav-readline">Readline</a></li> 3181cb0ef41Sopenharmony_ci<li><a href="repl.html" class="nav-repl">REPL</a></li> 3191cb0ef41Sopenharmony_ci<li><a href="report.html" class="nav-report">Report</a></li> 3201cb0ef41Sopenharmony_ci<li><a href="single-executable-applications.html" class="nav-single-executable-applications">Single executable applications</a></li> 3211cb0ef41Sopenharmony_ci<li><a href="stream.html" class="nav-stream">Stream</a></li> 3221cb0ef41Sopenharmony_ci<li><a href="string_decoder.html" class="nav-string_decoder">String decoder</a></li> 3231cb0ef41Sopenharmony_ci<li><a href="test.html" class="nav-test">Test runner</a></li> 3241cb0ef41Sopenharmony_ci<li><a href="timers.html" class="nav-timers">Timers</a></li> 3251cb0ef41Sopenharmony_ci<li><a href="tls.html" class="nav-tls">TLS/SSL</a></li> 3261cb0ef41Sopenharmony_ci<li><a href="tracing.html" class="nav-tracing">Trace events</a></li> 3271cb0ef41Sopenharmony_ci<li><a href="tty.html" class="nav-tty">TTY</a></li> 3281cb0ef41Sopenharmony_ci<li><a href="dgram.html" class="nav-dgram">UDP/datagram</a></li> 3291cb0ef41Sopenharmony_ci<li><a href="url.html" class="nav-url">URL</a></li> 3301cb0ef41Sopenharmony_ci<li><a href="util.html" class="nav-util">Utilities</a></li> 3311cb0ef41Sopenharmony_ci<li><a href="v8.html" class="nav-v8">V8</a></li> 3321cb0ef41Sopenharmony_ci<li><a href="vm.html" class="nav-vm">VM</a></li> 3331cb0ef41Sopenharmony_ci<li><a href="wasi.html" class="nav-wasi">WASI</a></li> 3341cb0ef41Sopenharmony_ci<li><a href="webcrypto.html" class="nav-webcrypto">Web Crypto API</a></li> 3351cb0ef41Sopenharmony_ci<li><a href="webstreams.html" class="nav-webstreams">Web Streams API</a></li> 3361cb0ef41Sopenharmony_ci<li><a href="worker_threads.html" class="nav-worker_threads">Worker threads</a></li> 3371cb0ef41Sopenharmony_ci<li><a href="zlib.html" class="nav-zlib">Zlib</a></li> 3381cb0ef41Sopenharmony_ci</ul> 3391cb0ef41Sopenharmony_ci<hr class="line"> 3401cb0ef41Sopenharmony_ci<ul> 3411cb0ef41Sopenharmony_ci<li><a href="https://github.com/nodejs/node" class="nav-https-github-com-nodejs-node">Code repository and issue tracker</a></li> 3421cb0ef41Sopenharmony_ci</ul></div> 3431cb0ef41Sopenharmony_ci </li> 3441cb0ef41Sopenharmony_ci 3451cb0ef41Sopenharmony_ci 3461cb0ef41Sopenharmony_ci <li class="picker-header"> 3471cb0ef41Sopenharmony_ci <a href="#"> 3481cb0ef41Sopenharmony_ci <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> 3491cb0ef41Sopenharmony_ci Other versions 3501cb0ef41Sopenharmony_ci </a> 3511cb0ef41Sopenharmony_ci <div class="picker"><ol id="alt-docs"><li><a href="https://nodejs.org/docs/latest-v21.x/api/perf_hooks.html">21.x</a></li> 3521cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v20.x/api/perf_hooks.html">20.x <b>LTS</b></a></li> 3531cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v19.x/api/perf_hooks.html">19.x</a></li> 3541cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v18.x/api/perf_hooks.html">18.x <b>LTS</b></a></li> 3551cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v17.x/api/perf_hooks.html">17.x</a></li> 3561cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v16.x/api/perf_hooks.html">16.x</a></li> 3571cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v15.x/api/perf_hooks.html">15.x</a></li> 3581cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v14.x/api/perf_hooks.html">14.x</a></li> 3591cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v13.x/api/perf_hooks.html">13.x</a></li> 3601cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v12.x/api/perf_hooks.html">12.x</a></li> 3611cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v11.x/api/perf_hooks.html">11.x</a></li> 3621cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v10.x/api/perf_hooks.html">10.x</a></li> 3631cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v9.x/api/perf_hooks.html">9.x</a></li> 3641cb0ef41Sopenharmony_ci<li><a href="https://nodejs.org/docs/latest-v8.x/api/perf_hooks.html">8.x</a></li></ol></div> 3651cb0ef41Sopenharmony_ci </li> 3661cb0ef41Sopenharmony_ci 3671cb0ef41Sopenharmony_ci <li class="picker-header"> 3681cb0ef41Sopenharmony_ci <a href="#"> 3691cb0ef41Sopenharmony_ci <span class="collapsed-arrow">►</span><span class="expanded-arrow">▼</span> 3701cb0ef41Sopenharmony_ci Options 3711cb0ef41Sopenharmony_ci </a> 3721cb0ef41Sopenharmony_ci 3731cb0ef41Sopenharmony_ci <div class="picker"> 3741cb0ef41Sopenharmony_ci <ul> 3751cb0ef41Sopenharmony_ci <li> 3761cb0ef41Sopenharmony_ci <a href="all.html">View on single page</a> 3771cb0ef41Sopenharmony_ci </li> 3781cb0ef41Sopenharmony_ci <li> 3791cb0ef41Sopenharmony_ci <a href="perf_hooks.json">View as JSON</a> 3801cb0ef41Sopenharmony_ci </li> 3811cb0ef41Sopenharmony_ci <li class="edit_on_github"><a href="https://github.com/nodejs/node/edit/main/doc/api/perf_hooks.md">Edit on GitHub</a></li> 3821cb0ef41Sopenharmony_ci </ul> 3831cb0ef41Sopenharmony_ci </div> 3841cb0ef41Sopenharmony_ci </li> 3851cb0ef41Sopenharmony_ci </ul> 3861cb0ef41Sopenharmony_ci </div> 3871cb0ef41Sopenharmony_ci <hr> 3881cb0ef41Sopenharmony_ci </header> 3891cb0ef41Sopenharmony_ci 3901cb0ef41Sopenharmony_ci <details id="toc" open><summary>Table of contents</summary><ul> 3911cb0ef41Sopenharmony_ci<li><span class="stability_2"><a href="#performance-measurement-apis">Performance measurement APIs</a></span> 3921cb0ef41Sopenharmony_ci<ul> 3931cb0ef41Sopenharmony_ci<li><a href="#perf_hooksperformance"><code>perf_hooks.performance</code></a> 3941cb0ef41Sopenharmony_ci<ul> 3951cb0ef41Sopenharmony_ci<li><a href="#performanceclearmarksname"><code>performance.clearMarks([name])</code></a></li> 3961cb0ef41Sopenharmony_ci<li><a href="#performanceclearmeasuresname"><code>performance.clearMeasures([name])</code></a></li> 3971cb0ef41Sopenharmony_ci<li><a href="#performanceclearresourcetimingsname"><code>performance.clearResourceTimings([name])</code></a></li> 3981cb0ef41Sopenharmony_ci<li><a href="#performanceeventlooputilizationutilization1-utilization2"><code>performance.eventLoopUtilization([utilization1[, utilization2]])</code></a></li> 3991cb0ef41Sopenharmony_ci<li><a href="#performancegetentries"><code>performance.getEntries()</code></a></li> 4001cb0ef41Sopenharmony_ci<li><a href="#performancegetentriesbynamename-type"><code>performance.getEntriesByName(name[, type])</code></a></li> 4011cb0ef41Sopenharmony_ci<li><a href="#performancegetentriesbytypetype"><code>performance.getEntriesByType(type)</code></a></li> 4021cb0ef41Sopenharmony_ci<li><a href="#performancemarkname-options"><code>performance.mark([name[, options]])</code></a></li> 4031cb0ef41Sopenharmony_ci<li><a href="#performancemarkresourcetimingtiminginfo-requestedurl-initiatortype-global-cachemode"><code>performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, global, cacheMode)</code></a></li> 4041cb0ef41Sopenharmony_ci<li><a href="#performancemeasurename-startmarkoroptions-endmark"><code>performance.measure(name[, startMarkOrOptions[, endMark]])</code></a></li> 4051cb0ef41Sopenharmony_ci<li><a href="#performancenodetiming"><code>performance.nodeTiming</code></a></li> 4061cb0ef41Sopenharmony_ci<li><a href="#performancenow"><code>performance.now()</code></a></li> 4071cb0ef41Sopenharmony_ci<li><a href="#performancesetresourcetimingbuffersizemaxsize"><code>performance.setResourceTimingBufferSize(maxSize)</code></a></li> 4081cb0ef41Sopenharmony_ci<li><a href="#performancetimeorigin"><code>performance.timeOrigin</code></a></li> 4091cb0ef41Sopenharmony_ci<li><a href="#performancetimerifyfn-options"><code>performance.timerify(fn[, options])</code></a></li> 4101cb0ef41Sopenharmony_ci<li><a href="#performancetojson"><code>performance.toJSON()</code></a> 4111cb0ef41Sopenharmony_ci<ul> 4121cb0ef41Sopenharmony_ci<li><a href="#event-resourcetimingbufferfull">Event: <code>'resourcetimingbufferfull'</code></a></li> 4131cb0ef41Sopenharmony_ci</ul> 4141cb0ef41Sopenharmony_ci</li> 4151cb0ef41Sopenharmony_ci</ul> 4161cb0ef41Sopenharmony_ci</li> 4171cb0ef41Sopenharmony_ci<li><a href="#class-performanceentry">Class: <code>PerformanceEntry</code></a> 4181cb0ef41Sopenharmony_ci<ul> 4191cb0ef41Sopenharmony_ci<li><a href="#performanceentrydetail"><code>performanceEntry.detail</code></a></li> 4201cb0ef41Sopenharmony_ci<li><a href="#performanceentryduration"><code>performanceEntry.duration</code></a></li> 4211cb0ef41Sopenharmony_ci<li><a href="#performanceentryentrytype"><code>performanceEntry.entryType</code></a></li> 4221cb0ef41Sopenharmony_ci<li><a href="#performanceentryflags"><code>performanceEntry.flags</code></a></li> 4231cb0ef41Sopenharmony_ci<li><a href="#performanceentryname"><code>performanceEntry.name</code></a></li> 4241cb0ef41Sopenharmony_ci<li><a href="#performanceentrykind"><code>performanceEntry.kind</code></a></li> 4251cb0ef41Sopenharmony_ci<li><a href="#performanceentrystarttime"><code>performanceEntry.startTime</code></a></li> 4261cb0ef41Sopenharmony_ci<li><a href="#garbage-collection-gc-details">Garbage Collection ('gc') Details</a></li> 4271cb0ef41Sopenharmony_ci<li><a href="#http-http-details">HTTP ('http') Details</a></li> 4281cb0ef41Sopenharmony_ci<li><a href="#http2-http2-details">HTTP/2 ('http2') Details</a></li> 4291cb0ef41Sopenharmony_ci<li><a href="#timerify-function-details">Timerify ('function') Details</a></li> 4301cb0ef41Sopenharmony_ci<li><a href="#net-net-details">Net ('net') Details</a></li> 4311cb0ef41Sopenharmony_ci<li><a href="#dns-dns-details">DNS ('dns') Details</a></li> 4321cb0ef41Sopenharmony_ci</ul> 4331cb0ef41Sopenharmony_ci</li> 4341cb0ef41Sopenharmony_ci<li><a href="#class-performancenodetiming">Class: <code>PerformanceNodeTiming</code></a> 4351cb0ef41Sopenharmony_ci<ul> 4361cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingbootstrapcomplete"><code>performanceNodeTiming.bootstrapComplete</code></a></li> 4371cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingenvironment"><code>performanceNodeTiming.environment</code></a></li> 4381cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingidletime"><code>performanceNodeTiming.idleTime</code></a></li> 4391cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingloopexit"><code>performanceNodeTiming.loopExit</code></a></li> 4401cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingloopstart"><code>performanceNodeTiming.loopStart</code></a></li> 4411cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingnodestart"><code>performanceNodeTiming.nodeStart</code></a></li> 4421cb0ef41Sopenharmony_ci<li><a href="#performancenodetimingv8start"><code>performanceNodeTiming.v8Start</code></a></li> 4431cb0ef41Sopenharmony_ci</ul> 4441cb0ef41Sopenharmony_ci</li> 4451cb0ef41Sopenharmony_ci<li><a href="#class-performanceresourcetiming">Class: <code>PerformanceResourceTiming</code></a> 4461cb0ef41Sopenharmony_ci<ul> 4471cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingworkerstart"><code>performanceResourceTiming.workerStart</code></a></li> 4481cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingredirectstart"><code>performanceResourceTiming.redirectStart</code></a></li> 4491cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingredirectend"><code>performanceResourceTiming.redirectEnd</code></a></li> 4501cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingfetchstart"><code>performanceResourceTiming.fetchStart</code></a></li> 4511cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingdomainlookupstart"><code>performanceResourceTiming.domainLookupStart</code></a></li> 4521cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingdomainlookupend"><code>performanceResourceTiming.domainLookupEnd</code></a></li> 4531cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingconnectstart"><code>performanceResourceTiming.connectStart</code></a></li> 4541cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingconnectend"><code>performanceResourceTiming.connectEnd</code></a></li> 4551cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingsecureconnectionstart"><code>performanceResourceTiming.secureConnectionStart</code></a></li> 4561cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingrequeststart"><code>performanceResourceTiming.requestStart</code></a></li> 4571cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingresponseend"><code>performanceResourceTiming.responseEnd</code></a></li> 4581cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingtransfersize"><code>performanceResourceTiming.transferSize</code></a></li> 4591cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingencodedbodysize"><code>performanceResourceTiming.encodedBodySize</code></a></li> 4601cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingdecodedbodysize"><code>performanceResourceTiming.decodedBodySize</code></a></li> 4611cb0ef41Sopenharmony_ci<li><a href="#performanceresourcetimingtojson"><code>performanceResourceTiming.toJSON()</code></a></li> 4621cb0ef41Sopenharmony_ci</ul> 4631cb0ef41Sopenharmony_ci</li> 4641cb0ef41Sopenharmony_ci<li><a href="#class-perf_hooksperformanceobserver">Class: <code>perf_hooks.PerformanceObserver</code></a> 4651cb0ef41Sopenharmony_ci<ul> 4661cb0ef41Sopenharmony_ci<li><a href="#performanceobserversupportedentrytypes"><code>PerformanceObserver.supportedEntryTypes</code></a></li> 4671cb0ef41Sopenharmony_ci<li><a href="#new-performanceobservercallback"><code>new PerformanceObserver(callback)</code></a></li> 4681cb0ef41Sopenharmony_ci<li><a href="#performanceobserverdisconnect"><code>performanceObserver.disconnect()</code></a></li> 4691cb0ef41Sopenharmony_ci<li><a href="#performanceobserverobserveoptions"><code>performanceObserver.observe(options)</code></a></li> 4701cb0ef41Sopenharmony_ci</ul> 4711cb0ef41Sopenharmony_ci</li> 4721cb0ef41Sopenharmony_ci<li><a href="#class-performanceobserverentrylist">Class: <code>PerformanceObserverEntryList</code></a> 4731cb0ef41Sopenharmony_ci<ul> 4741cb0ef41Sopenharmony_ci<li><a href="#performanceobserverentrylistgetentries"><code>performanceObserverEntryList.getEntries()</code></a></li> 4751cb0ef41Sopenharmony_ci<li><a href="#performanceobserverentrylistgetentriesbynamename-type"><code>performanceObserverEntryList.getEntriesByName(name[, type])</code></a></li> 4761cb0ef41Sopenharmony_ci<li><a href="#performanceobserverentrylistgetentriesbytypetype"><code>performanceObserverEntryList.getEntriesByType(type)</code></a></li> 4771cb0ef41Sopenharmony_ci</ul> 4781cb0ef41Sopenharmony_ci</li> 4791cb0ef41Sopenharmony_ci<li><a href="#perf_hookscreatehistogramoptions"><code>perf_hooks.createHistogram([options])</code></a></li> 4801cb0ef41Sopenharmony_ci<li><a href="#perf_hooksmonitoreventloopdelayoptions"><code>perf_hooks.monitorEventLoopDelay([options])</code></a></li> 4811cb0ef41Sopenharmony_ci<li><a href="#class-histogram">Class: <code>Histogram</code></a> 4821cb0ef41Sopenharmony_ci<ul> 4831cb0ef41Sopenharmony_ci<li><a href="#histogramcount"><code>histogram.count</code></a></li> 4841cb0ef41Sopenharmony_ci<li><a href="#histogramcountbigint"><code>histogram.countBigInt</code></a></li> 4851cb0ef41Sopenharmony_ci<li><a href="#histogramexceeds"><code>histogram.exceeds</code></a></li> 4861cb0ef41Sopenharmony_ci<li><a href="#histogramexceedsbigint"><code>histogram.exceedsBigInt</code></a></li> 4871cb0ef41Sopenharmony_ci<li><a href="#histogrammax"><code>histogram.max</code></a></li> 4881cb0ef41Sopenharmony_ci<li><a href="#histogrammaxbigint"><code>histogram.maxBigInt</code></a></li> 4891cb0ef41Sopenharmony_ci<li><a href="#histogrammean"><code>histogram.mean</code></a></li> 4901cb0ef41Sopenharmony_ci<li><a href="#histogrammin"><code>histogram.min</code></a></li> 4911cb0ef41Sopenharmony_ci<li><a href="#histogramminbigint"><code>histogram.minBigInt</code></a></li> 4921cb0ef41Sopenharmony_ci<li><a href="#histogrampercentilepercentile"><code>histogram.percentile(percentile)</code></a></li> 4931cb0ef41Sopenharmony_ci<li><a href="#histogrampercentilebigintpercentile"><code>histogram.percentileBigInt(percentile)</code></a></li> 4941cb0ef41Sopenharmony_ci<li><a href="#histogrampercentiles"><code>histogram.percentiles</code></a></li> 4951cb0ef41Sopenharmony_ci<li><a href="#histogrampercentilesbigint"><code>histogram.percentilesBigInt</code></a></li> 4961cb0ef41Sopenharmony_ci<li><a href="#histogramreset"><code>histogram.reset()</code></a></li> 4971cb0ef41Sopenharmony_ci<li><a href="#histogramstddev"><code>histogram.stddev</code></a></li> 4981cb0ef41Sopenharmony_ci</ul> 4991cb0ef41Sopenharmony_ci</li> 5001cb0ef41Sopenharmony_ci<li><a href="#class-intervalhistogram-extends-histogram">Class: <code>IntervalHistogram extends Histogram</code></a> 5011cb0ef41Sopenharmony_ci<ul> 5021cb0ef41Sopenharmony_ci<li><a href="#histogramdisable"><code>histogram.disable()</code></a></li> 5031cb0ef41Sopenharmony_ci<li><a href="#histogramenable"><code>histogram.enable()</code></a></li> 5041cb0ef41Sopenharmony_ci<li><a href="#cloning-an-intervalhistogram">Cloning an <code>IntervalHistogram</code></a></li> 5051cb0ef41Sopenharmony_ci</ul> 5061cb0ef41Sopenharmony_ci</li> 5071cb0ef41Sopenharmony_ci<li><a href="#class-recordablehistogram-extends-histogram">Class: <code>RecordableHistogram extends Histogram</code></a> 5081cb0ef41Sopenharmony_ci<ul> 5091cb0ef41Sopenharmony_ci<li><a href="#histogramaddother"><code>histogram.add(other)</code></a></li> 5101cb0ef41Sopenharmony_ci<li><a href="#histogramrecordval"><code>histogram.record(val)</code></a></li> 5111cb0ef41Sopenharmony_ci<li><a href="#histogramrecorddelta"><code>histogram.recordDelta()</code></a></li> 5121cb0ef41Sopenharmony_ci</ul> 5131cb0ef41Sopenharmony_ci</li> 5141cb0ef41Sopenharmony_ci<li><a href="#examples">Examples</a> 5151cb0ef41Sopenharmony_ci<ul> 5161cb0ef41Sopenharmony_ci<li><a href="#measuring-the-duration-of-async-operations">Measuring the duration of async operations</a></li> 5171cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-it-takes-to-load-dependencies">Measuring how long it takes to load dependencies</a></li> 5181cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-one-http-round-trip-takes">Measuring how long one HTTP round-trip takes</a></li> 5191cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-the-netconnect-only-for-tcp-takes-when-the-connection-is-successful">Measuring how long the <code>net.connect</code> (only for TCP) takes when the connection is successful</a></li> 5201cb0ef41Sopenharmony_ci<li><a href="#measuring-how-long-the-dns-takes-when-the-request-is-successful">Measuring how long the DNS takes when the request is successful</a></li> 5211cb0ef41Sopenharmony_ci</ul> 5221cb0ef41Sopenharmony_ci</li> 5231cb0ef41Sopenharmony_ci</ul> 5241cb0ef41Sopenharmony_ci</li> 5251cb0ef41Sopenharmony_ci</ul></details> 5261cb0ef41Sopenharmony_ci 5271cb0ef41Sopenharmony_ci <div id="apicontent"> 5281cb0ef41Sopenharmony_ci <h2>Performance measurement APIs<span><a class="mark" href="#performance-measurement-apis" id="performance-measurement-apis">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_measurement_apis"></a></h2> 5291cb0ef41Sopenharmony_ci 5301cb0ef41Sopenharmony_ci<p></p><div class="api_stability api_stability_2"><a href="documentation.html#stability-index">Stability: 2</a> - Stable</div><p></p> 5311cb0ef41Sopenharmony_ci<p><strong>Source Code:</strong> <a href="https://github.com/nodejs/node/blob/v18.20.1/lib/perf_hooks.js">lib/perf_hooks.js</a></p> 5321cb0ef41Sopenharmony_ci<p>This module provides an implementation of a subset of the W3C 5331cb0ef41Sopenharmony_ci<a href="https://w3c.github.io/perf-timing-primer/">Web Performance APIs</a> as well as additional APIs for 5341cb0ef41Sopenharmony_ciNode.js-specific performance measurements.</p> 5351cb0ef41Sopenharmony_ci<p>Node.js supports the following <a href="https://w3c.github.io/perf-timing-primer/">Web Performance APIs</a>:</p> 5361cb0ef41Sopenharmony_ci<ul> 5371cb0ef41Sopenharmony_ci<li><a href="https://www.w3.org/TR/hr-time-2">High Resolution Time</a></li> 5381cb0ef41Sopenharmony_ci<li><a href="https://w3c.github.io/performance-timeline/">Performance Timeline</a></li> 5391cb0ef41Sopenharmony_ci<li><a href="https://www.w3.org/TR/user-timing/">User Timing</a></li> 5401cb0ef41Sopenharmony_ci<li><a href="https://www.w3.org/TR/resource-timing-2/">Resource Timing</a></li> 5411cb0ef41Sopenharmony_ci</ul> 5421cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { <span class="hljs-title class_">PerformanceObserver</span>, performance } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 5431cb0ef41Sopenharmony_ci 5441cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">items</span>) =></span> { 5451cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(items.<span class="hljs-title function_">getEntries</span>()[<span class="hljs-number">0</span>].<span class="hljs-property">duration</span>); 5461cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 5471cb0ef41Sopenharmony_ci}); 5481cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">type</span>: <span class="hljs-string">'measure'</span> }); 5491cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">measure</span>(<span class="hljs-string">'Start to Now'</span>); 5501cb0ef41Sopenharmony_ci 5511cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'A'</span>); 5521cb0ef41Sopenharmony_ci<span class="hljs-title function_">doSomeLongRunningProcess</span>(<span class="hljs-function">() =></span> { 5531cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">measure</span>(<span class="hljs-string">'A to Now'</span>, <span class="hljs-string">'A'</span>); 5541cb0ef41Sopenharmony_ci 5551cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'B'</span>); 5561cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">measure</span>(<span class="hljs-string">'A to B'</span>, <span class="hljs-string">'A'</span>, <span class="hljs-string">'B'</span>); 5571cb0ef41Sopenharmony_ci});</code> <button class="copy-button">copy</button></pre> 5581cb0ef41Sopenharmony_ci<section><h3><code>perf_hooks.performance</code><span><a class="mark" href="#perf_hooksperformance" id="perf_hooksperformance">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_perf_hooks_performance"></a></h3> 5591cb0ef41Sopenharmony_ci<div class="api_metadata"> 5601cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 5611cb0ef41Sopenharmony_ci</div> 5621cb0ef41Sopenharmony_ci<p>An object that can be used to collect performance metrics from the current 5631cb0ef41Sopenharmony_ciNode.js instance. It is similar to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/performance"><code>window.performance</code></a> in browsers.</p> 5641cb0ef41Sopenharmony_ci<h4><code>performance.clearMarks([name])</code><span><a class="mark" href="#performanceclearmarksname" id="performanceclearmarksname">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_clearmarks_name"></a></h4> 5651cb0ef41Sopenharmony_ci<div class="api_metadata"> 5661cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 5671cb0ef41Sopenharmony_ci</div> 5681cb0ef41Sopenharmony_ci<ul> 5691cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 5701cb0ef41Sopenharmony_ci</ul> 5711cb0ef41Sopenharmony_ci<p>If <code>name</code> is not provided, removes all <code>PerformanceMark</code> objects from the 5721cb0ef41Sopenharmony_ciPerformance Timeline. If <code>name</code> is provided, removes only the named mark.</p> 5731cb0ef41Sopenharmony_ci<h4><code>performance.clearMeasures([name])</code><span><a class="mark" href="#performanceclearmeasuresname" id="performanceclearmeasuresname">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_clearmeasures_name"></a></h4> 5741cb0ef41Sopenharmony_ci<div class="api_metadata"> 5751cb0ef41Sopenharmony_ci<span>Added in: v16.7.0</span> 5761cb0ef41Sopenharmony_ci</div> 5771cb0ef41Sopenharmony_ci<ul> 5781cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 5791cb0ef41Sopenharmony_ci</ul> 5801cb0ef41Sopenharmony_ci<p>If <code>name</code> is not provided, removes all <code>PerformanceMeasure</code> objects from the 5811cb0ef41Sopenharmony_ciPerformance Timeline. If <code>name</code> is provided, removes only the named measure.</p> 5821cb0ef41Sopenharmony_ci<h4><code>performance.clearResourceTimings([name])</code><span><a class="mark" href="#performanceclearresourcetimingsname" id="performanceclearresourcetimingsname">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_clearresourcetimings_name"></a></h4> 5831cb0ef41Sopenharmony_ci<div class="api_metadata"> 5841cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 5851cb0ef41Sopenharmony_ci</div> 5861cb0ef41Sopenharmony_ci<ul> 5871cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 5881cb0ef41Sopenharmony_ci</ul> 5891cb0ef41Sopenharmony_ci<p>If <code>name</code> is not provided, removes all <code>PerformanceResourceTiming</code> objects from 5901cb0ef41Sopenharmony_cithe Resource Timeline. If <code>name</code> is provided, removes only the named resource.</p> 5911cb0ef41Sopenharmony_ci<h4><code>performance.eventLoopUtilization([utilization1[, utilization2]])</code><span><a class="mark" href="#performanceeventlooputilizationutilization1-utilization2" id="performanceeventlooputilizationutilization1-utilization2">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_eventlooputilization_utilization1_utilization2"></a></h4> 5921cb0ef41Sopenharmony_ci<div class="api_metadata"> 5931cb0ef41Sopenharmony_ci<span>Added in: v14.10.0, v12.19.0</span> 5941cb0ef41Sopenharmony_ci</div> 5951cb0ef41Sopenharmony_ci<ul> 5961cb0ef41Sopenharmony_ci<li><code>utilization1</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> The result of a previous call to 5971cb0ef41Sopenharmony_ci<code>eventLoopUtilization()</code>.</li> 5981cb0ef41Sopenharmony_ci<li><code>utilization2</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> The result of a previous call to 5991cb0ef41Sopenharmony_ci<code>eventLoopUtilization()</code> prior to <code>utilization1</code>.</li> 6001cb0ef41Sopenharmony_ci<li>Returns <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 6011cb0ef41Sopenharmony_ci<ul> 6021cb0ef41Sopenharmony_ci<li><code>idle</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 6031cb0ef41Sopenharmony_ci<li><code>active</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 6041cb0ef41Sopenharmony_ci<li><code>utilization</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 6051cb0ef41Sopenharmony_ci</ul> 6061cb0ef41Sopenharmony_ci</li> 6071cb0ef41Sopenharmony_ci</ul> 6081cb0ef41Sopenharmony_ci<p>The <code>eventLoopUtilization()</code> method returns an object that contains the 6091cb0ef41Sopenharmony_cicumulative duration of time the event loop has been both idle and active as a 6101cb0ef41Sopenharmony_cihigh resolution milliseconds timer. The <code>utilization</code> value is the calculated 6111cb0ef41Sopenharmony_ciEvent Loop Utilization (ELU).</p> 6121cb0ef41Sopenharmony_ci<p>If bootstrapping has not yet finished on the main thread the properties have 6131cb0ef41Sopenharmony_cithe value of <code>0</code>. The ELU is immediately available on <a href="worker_threads.html#worker-threads">Worker threads</a> since 6141cb0ef41Sopenharmony_cibootstrap happens within the event loop.</p> 6151cb0ef41Sopenharmony_ci<p>Both <code>utilization1</code> and <code>utilization2</code> are optional parameters.</p> 6161cb0ef41Sopenharmony_ci<p>If <code>utilization1</code> is passed, then the delta between the current call's <code>active</code> 6171cb0ef41Sopenharmony_ciand <code>idle</code> times, as well as the corresponding <code>utilization</code> value are 6181cb0ef41Sopenharmony_cicalculated and returned (similar to <a href="process.html#processhrtimetime"><code>process.hrtime()</code></a>).</p> 6191cb0ef41Sopenharmony_ci<p>If <code>utilization1</code> and <code>utilization2</code> are both passed, then the delta is 6201cb0ef41Sopenharmony_cicalculated between the two arguments. This is a convenience option because, 6211cb0ef41Sopenharmony_ciunlike <a href="process.html#processhrtimetime"><code>process.hrtime()</code></a>, calculating the ELU is more complex than a 6221cb0ef41Sopenharmony_cisingle subtraction.</p> 6231cb0ef41Sopenharmony_ci<p>ELU is similar to CPU utilization, except that it only measures event loop 6241cb0ef41Sopenharmony_cistatistics and not CPU usage. It represents the percentage of time the event 6251cb0ef41Sopenharmony_ciloop has spent outside the event loop's event provider (e.g. <code>epoll_wait</code>). 6261cb0ef41Sopenharmony_ciNo other CPU idle time is taken into consideration. The following is an example 6271cb0ef41Sopenharmony_ciof how a mostly idle process will have a high ELU.</p> 6281cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-meta">'use strict'</span>; 6291cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { eventLoopUtilization } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>).<span class="hljs-property">performance</span>; 6301cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { spawnSync } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:child_process'</span>); 6311cb0ef41Sopenharmony_ci 6321cb0ef41Sopenharmony_ci<span class="hljs-title function_">setImmediate</span>(<span class="hljs-function">() =></span> { 6331cb0ef41Sopenharmony_ci <span class="hljs-keyword">const</span> elu = <span class="hljs-title function_">eventLoopUtilization</span>(); 6341cb0ef41Sopenharmony_ci <span class="hljs-title function_">spawnSync</span>(<span class="hljs-string">'sleep'</span>, [<span class="hljs-string">'5'</span>]); 6351cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-title function_">eventLoopUtilization</span>(elu).<span class="hljs-property">utilization</span>); 6361cb0ef41Sopenharmony_ci});</code> <button class="copy-button">copy</button></pre> 6371cb0ef41Sopenharmony_ci<p>Although the CPU is mostly idle while running this script, the value of 6381cb0ef41Sopenharmony_ci<code>utilization</code> is <code>1</code>. This is because the call to 6391cb0ef41Sopenharmony_ci<a href="child_process.html#child_processspawnsynccommand-args-options"><code>child_process.spawnSync()</code></a> blocks the event loop from proceeding.</p> 6401cb0ef41Sopenharmony_ci<p>Passing in a user-defined object instead of the result of a previous call to 6411cb0ef41Sopenharmony_ci<code>eventLoopUtilization()</code> will lead to undefined behavior. The return values 6421cb0ef41Sopenharmony_ciare not guaranteed to reflect any correct state of the event loop.</p> 6431cb0ef41Sopenharmony_ci<h4><code>performance.getEntries()</code><span><a class="mark" href="#performancegetentries" id="performancegetentries">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_getentries"></a></h4> 6441cb0ef41Sopenharmony_ci<div class="api_metadata"> 6451cb0ef41Sopenharmony_ci<span>Added in: v16.7.0</span> 6461cb0ef41Sopenharmony_ci</div> 6471cb0ef41Sopenharmony_ci<ul> 6481cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry[]></a></li> 6491cb0ef41Sopenharmony_ci</ul> 6501cb0ef41Sopenharmony_ci<p>Returns a list of <code>PerformanceEntry</code> objects in chronological order with 6511cb0ef41Sopenharmony_cirespect to <code>performanceEntry.startTime</code>. If you are only interested in 6521cb0ef41Sopenharmony_ciperformance entries of certain types or that have certain names, see 6531cb0ef41Sopenharmony_ci<code>performance.getEntriesByType()</code> and <code>performance.getEntriesByName()</code>.</p> 6541cb0ef41Sopenharmony_ci<h4><code>performance.getEntriesByName(name[, type])</code><span><a class="mark" href="#performancegetentriesbynamename-type" id="performancegetentriesbynamename-type">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_getentriesbyname_name_type"></a></h4> 6551cb0ef41Sopenharmony_ci<div class="api_metadata"> 6561cb0ef41Sopenharmony_ci<span>Added in: v16.7.0</span> 6571cb0ef41Sopenharmony_ci</div> 6581cb0ef41Sopenharmony_ci<ul> 6591cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 6601cb0ef41Sopenharmony_ci<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 6611cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry[]></a></li> 6621cb0ef41Sopenharmony_ci</ul> 6631cb0ef41Sopenharmony_ci<p>Returns a list of <code>PerformanceEntry</code> objects in chronological order 6641cb0ef41Sopenharmony_ciwith respect to <code>performanceEntry.startTime</code> whose <code>performanceEntry.name</code> is 6651cb0ef41Sopenharmony_ciequal to <code>name</code>, and optionally, whose <code>performanceEntry.entryType</code> is equal to 6661cb0ef41Sopenharmony_ci<code>type</code>.</p> 6671cb0ef41Sopenharmony_ci<h4><code>performance.getEntriesByType(type)</code><span><a class="mark" href="#performancegetentriesbytypetype" id="performancegetentriesbytypetype">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_getentriesbytype_type"></a></h4> 6681cb0ef41Sopenharmony_ci<div class="api_metadata"> 6691cb0ef41Sopenharmony_ci<span>Added in: v16.7.0</span> 6701cb0ef41Sopenharmony_ci</div> 6711cb0ef41Sopenharmony_ci<ul> 6721cb0ef41Sopenharmony_ci<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 6731cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry[]></a></li> 6741cb0ef41Sopenharmony_ci</ul> 6751cb0ef41Sopenharmony_ci<p>Returns a list of <code>PerformanceEntry</code> objects in chronological order 6761cb0ef41Sopenharmony_ciwith respect to <code>performanceEntry.startTime</code> whose <code>performanceEntry.entryType</code> 6771cb0ef41Sopenharmony_ciis equal to <code>type</code>.</p> 6781cb0ef41Sopenharmony_ci<h4><code>performance.mark([name[, options]])</code><span><a class="mark" href="#performancemarkname-options" id="performancemarkname-options">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_mark_name_options"></a></h4> 6791cb0ef41Sopenharmony_ci<div class="api_metadata"> 6801cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 6811cb0ef41Sopenharmony_ci<table> 6821cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 6831cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 6841cb0ef41Sopenharmony_ci<td><p>Updated to conform to the User Timing Level 3 specification.</p></td></tr> 6851cb0ef41Sopenharmony_ci<tr><td>v8.5.0</td> 6861cb0ef41Sopenharmony_ci<td><p><span>Added in: v8.5.0</span></p></td></tr> 6871cb0ef41Sopenharmony_ci</tbody></table> 6881cb0ef41Sopenharmony_ci</details> 6891cb0ef41Sopenharmony_ci</div> 6901cb0ef41Sopenharmony_ci<ul> 6911cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 6921cb0ef41Sopenharmony_ci<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 6931cb0ef41Sopenharmony_ci<ul> 6941cb0ef41Sopenharmony_ci<li><code>detail</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types" class="type"><any></a> Additional optional detail to include with the mark.</li> 6951cb0ef41Sopenharmony_ci<li><code>startTime</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> An optional timestamp to be used as the mark time. 6961cb0ef41Sopenharmony_ci<strong>Default</strong>: <code>performance.now()</code>.</li> 6971cb0ef41Sopenharmony_ci</ul> 6981cb0ef41Sopenharmony_ci</li> 6991cb0ef41Sopenharmony_ci</ul> 7001cb0ef41Sopenharmony_ci<p>Creates a new <code>PerformanceMark</code> entry in the Performance Timeline. A 7011cb0ef41Sopenharmony_ci<code>PerformanceMark</code> is a subclass of <code>PerformanceEntry</code> whose 7021cb0ef41Sopenharmony_ci<code>performanceEntry.entryType</code> is always <code>'mark'</code>, and whose 7031cb0ef41Sopenharmony_ci<code>performanceEntry.duration</code> is always <code>0</code>. Performance marks are used 7041cb0ef41Sopenharmony_cito mark specific significant moments in the Performance Timeline.</p> 7051cb0ef41Sopenharmony_ci<p>The created <code>PerformanceMark</code> entry is put in the global Performance Timeline 7061cb0ef41Sopenharmony_ciand can be queried with <code>performance.getEntries</code>, 7071cb0ef41Sopenharmony_ci<code>performance.getEntriesByName</code>, and <code>performance.getEntriesByType</code>. When the 7081cb0ef41Sopenharmony_ciobservation is performed, the entries should be cleared from the global 7091cb0ef41Sopenharmony_ciPerformance Timeline manually with <code>performance.clearMarks</code>.</p> 7101cb0ef41Sopenharmony_ci<h4><code>performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, global, cacheMode)</code><span><a class="mark" href="#performancemarkresourcetimingtiminginfo-requestedurl-initiatortype-global-cachemode" id="performancemarkresourcetimingtiminginfo-requestedurl-initiatortype-global-cachemode">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_markresourcetiming_timinginfo_requestedurl_initiatortype_global_cachemode"></a></h4> 7111cb0ef41Sopenharmony_ci<div class="api_metadata"> 7121cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 7131cb0ef41Sopenharmony_ci</div> 7141cb0ef41Sopenharmony_ci<ul> 7151cb0ef41Sopenharmony_ci<li><code>timingInfo</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> <a href="https://fetch.spec.whatwg.org/#fetch-timing-info">Fetch Timing Info</a></li> 7161cb0ef41Sopenharmony_ci<li><code>requestedUrl</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> The resource url</li> 7171cb0ef41Sopenharmony_ci<li><code>initiatorType</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> The initiator name, e.g: 'fetch'</li> 7181cb0ef41Sopenharmony_ci<li><code>global</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a></li> 7191cb0ef41Sopenharmony_ci<li><code>cacheMode</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> The cache mode must be an empty string ('') or 'local'</li> 7201cb0ef41Sopenharmony_ci</ul> 7211cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 7221cb0ef41Sopenharmony_ci<p>Creates a new <code>PerformanceResourceTiming</code> entry in the Resource Timeline. A 7231cb0ef41Sopenharmony_ci<code>PerformanceResourceTiming</code> is a subclass of <code>PerformanceEntry</code> whose 7241cb0ef41Sopenharmony_ci<code>performanceEntry.entryType</code> is always <code>'resource'</code>. Performance resources 7251cb0ef41Sopenharmony_ciare used to mark moments in the Resource Timeline.</p> 7261cb0ef41Sopenharmony_ci<p>The created <code>PerformanceMark</code> entry is put in the global Resource Timeline 7271cb0ef41Sopenharmony_ciand can be queried with <code>performance.getEntries</code>, 7281cb0ef41Sopenharmony_ci<code>performance.getEntriesByName</code>, and <code>performance.getEntriesByType</code>. When the 7291cb0ef41Sopenharmony_ciobservation is performed, the entries should be cleared from the global 7301cb0ef41Sopenharmony_ciPerformance Timeline manually with <code>performance.clearResourceTimings</code>.</p> 7311cb0ef41Sopenharmony_ci<h4><code>performance.measure(name[, startMarkOrOptions[, endMark]])</code><span><a class="mark" href="#performancemeasurename-startmarkoroptions-endmark" id="performancemeasurename-startmarkoroptions-endmark">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_measure_name_startmarkoroptions_endmark"></a></h4> 7321cb0ef41Sopenharmony_ci<div class="api_metadata"> 7331cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 7341cb0ef41Sopenharmony_ci<table> 7351cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 7361cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 7371cb0ef41Sopenharmony_ci<td><p>Updated to conform to the User Timing Level 3 specification.</p></td></tr> 7381cb0ef41Sopenharmony_ci<tr><td>v13.13.0, v12.16.3</td> 7391cb0ef41Sopenharmony_ci<td><p>Make <code>startMark</code> and <code>endMark</code> parameters optional.</p></td></tr> 7401cb0ef41Sopenharmony_ci<tr><td>v8.5.0</td> 7411cb0ef41Sopenharmony_ci<td><p><span>Added in: v8.5.0</span></p></td></tr> 7421cb0ef41Sopenharmony_ci</tbody></table> 7431cb0ef41Sopenharmony_ci</details> 7441cb0ef41Sopenharmony_ci</div> 7451cb0ef41Sopenharmony_ci<ul> 7461cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 7471cb0ef41Sopenharmony_ci<li><code>startMarkOrOptions</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> Optional. 7481cb0ef41Sopenharmony_ci<ul> 7491cb0ef41Sopenharmony_ci<li><code>detail</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types" class="type"><any></a> Additional optional detail to include with the measure.</li> 7501cb0ef41Sopenharmony_ci<li><code>duration</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> Duration between start and end times.</li> 7511cb0ef41Sopenharmony_ci<li><code>end</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Timestamp to be used as the end time, or a string 7521cb0ef41Sopenharmony_ciidentifying a previously recorded mark.</li> 7531cb0ef41Sopenharmony_ci<li><code>start</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Timestamp to be used as the start time, or a string 7541cb0ef41Sopenharmony_ciidentifying a previously recorded mark.</li> 7551cb0ef41Sopenharmony_ci</ul> 7561cb0ef41Sopenharmony_ci</li> 7571cb0ef41Sopenharmony_ci<li><code>endMark</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Optional. Must be omitted if <code>startMarkOrOptions</code> is an 7581cb0ef41Sopenharmony_ci<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a>.</li> 7591cb0ef41Sopenharmony_ci</ul> 7601cb0ef41Sopenharmony_ci<p>Creates a new <code>PerformanceMeasure</code> entry in the Performance Timeline. A 7611cb0ef41Sopenharmony_ci<code>PerformanceMeasure</code> is a subclass of <code>PerformanceEntry</code> whose 7621cb0ef41Sopenharmony_ci<code>performanceEntry.entryType</code> is always <code>'measure'</code>, and whose 7631cb0ef41Sopenharmony_ci<code>performanceEntry.duration</code> measures the number of milliseconds elapsed since 7641cb0ef41Sopenharmony_ci<code>startMark</code> and <code>endMark</code>.</p> 7651cb0ef41Sopenharmony_ci<p>The <code>startMark</code> argument may identify any <em>existing</em> <code>PerformanceMark</code> in the 7661cb0ef41Sopenharmony_ciPerformance Timeline, or <em>may</em> identify any of the timestamp properties 7671cb0ef41Sopenharmony_ciprovided by the <code>PerformanceNodeTiming</code> class. If the named <code>startMark</code> does 7681cb0ef41Sopenharmony_cinot exist, an error is thrown.</p> 7691cb0ef41Sopenharmony_ci<p>The optional <code>endMark</code> argument must identify any <em>existing</em> <code>PerformanceMark</code> 7701cb0ef41Sopenharmony_ciin the Performance Timeline or any of the timestamp properties provided by the 7711cb0ef41Sopenharmony_ci<code>PerformanceNodeTiming</code> class. <code>endMark</code> will be <code>performance.now()</code> 7721cb0ef41Sopenharmony_ciif no parameter is passed, otherwise if the named <code>endMark</code> does not exist, an 7731cb0ef41Sopenharmony_cierror will be thrown.</p> 7741cb0ef41Sopenharmony_ci<p>The created <code>PerformanceMeasure</code> entry is put in the global Performance Timeline 7751cb0ef41Sopenharmony_ciand can be queried with <code>performance.getEntries</code>, 7761cb0ef41Sopenharmony_ci<code>performance.getEntriesByName</code>, and <code>performance.getEntriesByType</code>. When the 7771cb0ef41Sopenharmony_ciobservation is performed, the entries should be cleared from the global 7781cb0ef41Sopenharmony_ciPerformance Timeline manually with <code>performance.clearMeasures</code>.</p> 7791cb0ef41Sopenharmony_ci<h4><code>performance.nodeTiming</code><span><a class="mark" href="#performancenodetiming" id="performancenodetiming">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_nodetiming"></a></h4> 7801cb0ef41Sopenharmony_ci<div class="api_metadata"> 7811cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 7821cb0ef41Sopenharmony_ci</div> 7831cb0ef41Sopenharmony_ci<ul> 7841cb0ef41Sopenharmony_ci<li><a href="perf_hooks.html#class-performancenodetiming" class="type"><PerformanceNodeTiming></a></li> 7851cb0ef41Sopenharmony_ci</ul> 7861cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 7871cb0ef41Sopenharmony_ci<p>An instance of the <code>PerformanceNodeTiming</code> class that provides performance 7881cb0ef41Sopenharmony_cimetrics for specific Node.js operational milestones.</p> 7891cb0ef41Sopenharmony_ci<h4><code>performance.now()</code><span><a class="mark" href="#performancenow" id="performancenow">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_now"></a></h4> 7901cb0ef41Sopenharmony_ci<div class="api_metadata"> 7911cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 7921cb0ef41Sopenharmony_ci</div> 7931cb0ef41Sopenharmony_ci<ul> 7941cb0ef41Sopenharmony_ci<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 7951cb0ef41Sopenharmony_ci</ul> 7961cb0ef41Sopenharmony_ci<p>Returns the current high resolution millisecond timestamp, where 0 represents 7971cb0ef41Sopenharmony_cithe start of the current <code>node</code> process.</p> 7981cb0ef41Sopenharmony_ci<h4><code>performance.setResourceTimingBufferSize(maxSize)</code><span><a class="mark" href="#performancesetresourcetimingbuffersizemaxsize" id="performancesetresourcetimingbuffersizemaxsize">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_setresourcetimingbuffersize_maxsize"></a></h4> 7991cb0ef41Sopenharmony_ci<div class="api_metadata"> 8001cb0ef41Sopenharmony_ci<span>Added in: v18.8.0</span> 8011cb0ef41Sopenharmony_ci</div> 8021cb0ef41Sopenharmony_ci<p>Sets the global performance resource timing buffer size to the specified number 8031cb0ef41Sopenharmony_ciof "resource" type performance entry objects.</p> 8041cb0ef41Sopenharmony_ci<p>By default the max buffer size is set to 250.</p> 8051cb0ef41Sopenharmony_ci<h4><code>performance.timeOrigin</code><span><a class="mark" href="#performancetimeorigin" id="performancetimeorigin">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_timeorigin"></a></h4> 8061cb0ef41Sopenharmony_ci<div class="api_metadata"> 8071cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 8081cb0ef41Sopenharmony_ci</div> 8091cb0ef41Sopenharmony_ci<ul> 8101cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 8111cb0ef41Sopenharmony_ci</ul> 8121cb0ef41Sopenharmony_ci<p>The <a href="https://w3c.github.io/hr-time/#dom-performance-timeorigin"><code>timeOrigin</code></a> specifies the high resolution millisecond timestamp at 8131cb0ef41Sopenharmony_ciwhich the current <code>node</code> process began, measured in Unix time.</p> 8141cb0ef41Sopenharmony_ci<h4><code>performance.timerify(fn[, options])</code><span><a class="mark" href="#performancetimerifyfn-options" id="performancetimerifyfn-options">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_timerify_fn_options"></a></h4> 8151cb0ef41Sopenharmony_ci<div class="api_metadata"> 8161cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 8171cb0ef41Sopenharmony_ci<table> 8181cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 8191cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 8201cb0ef41Sopenharmony_ci<td><p>Added the histogram option.</p></td></tr> 8211cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 8221cb0ef41Sopenharmony_ci<td><p>Re-implemented to use pure-JavaScript and the ability to time async functions.</p></td></tr> 8231cb0ef41Sopenharmony_ci<tr><td>v8.5.0</td> 8241cb0ef41Sopenharmony_ci<td><p><span>Added in: v8.5.0</span></p></td></tr> 8251cb0ef41Sopenharmony_ci</tbody></table> 8261cb0ef41Sopenharmony_ci</details> 8271cb0ef41Sopenharmony_ci</div> 8281cb0ef41Sopenharmony_ci<ul> 8291cb0ef41Sopenharmony_ci<li><code>fn</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a></li> 8301cb0ef41Sopenharmony_ci<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 8311cb0ef41Sopenharmony_ci<ul> 8321cb0ef41Sopenharmony_ci<li><code>histogram</code> <a href="perf_hooks.html#class-recordablehistogram-extends-histogram" class="type"><RecordableHistogram></a> A histogram object created using 8331cb0ef41Sopenharmony_ci<code>perf_hooks.createHistogram()</code> that will record runtime durations in 8341cb0ef41Sopenharmony_cinanoseconds.</li> 8351cb0ef41Sopenharmony_ci</ul> 8361cb0ef41Sopenharmony_ci</li> 8371cb0ef41Sopenharmony_ci</ul> 8381cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 8391cb0ef41Sopenharmony_ci<p>Wraps a function within a new function that measures the running time of the 8401cb0ef41Sopenharmony_ciwrapped function. A <code>PerformanceObserver</code> must be subscribed to the <code>'function'</code> 8411cb0ef41Sopenharmony_cievent type in order for the timing details to be accessed.</p> 8421cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { 8431cb0ef41Sopenharmony_ci performance, 8441cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 8451cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 8461cb0ef41Sopenharmony_ci 8471cb0ef41Sopenharmony_ci<span class="hljs-keyword">function</span> <span class="hljs-title function_">someFunction</span>(<span class="hljs-params"></span>) { 8481cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">'hello world'</span>); 8491cb0ef41Sopenharmony_ci} 8501cb0ef41Sopenharmony_ci 8511cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> wrapped = performance.<span class="hljs-title function_">timerify</span>(someFunction); 8521cb0ef41Sopenharmony_ci 8531cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">list</span>) =></span> { 8541cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(list.<span class="hljs-title function_">getEntries</span>()[<span class="hljs-number">0</span>].<span class="hljs-property">duration</span>); 8551cb0ef41Sopenharmony_ci 8561cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 8571cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 8581cb0ef41Sopenharmony_ci obs.<span class="hljs-title function_">disconnect</span>(); 8591cb0ef41Sopenharmony_ci}); 8601cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'function'</span>] }); 8611cb0ef41Sopenharmony_ci 8621cb0ef41Sopenharmony_ci<span class="hljs-comment">// A performance timeline entry will be created</span> 8631cb0ef41Sopenharmony_ci<span class="hljs-title function_">wrapped</span>();</code> <button class="copy-button">copy</button></pre> 8641cb0ef41Sopenharmony_ci<p>If the wrapped function returns a promise, a finally handler will be attached 8651cb0ef41Sopenharmony_cito the promise and the duration will be reported once the finally handler is 8661cb0ef41Sopenharmony_ciinvoked.</p> 8671cb0ef41Sopenharmony_ci<h4><code>performance.toJSON()</code><span><a class="mark" href="#performancetojson" id="performancetojson">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performance_tojson"></a></h4> 8681cb0ef41Sopenharmony_ci<div class="api_metadata"> 8691cb0ef41Sopenharmony_ci<span>Added in: v16.1.0</span> 8701cb0ef41Sopenharmony_ci</div> 8711cb0ef41Sopenharmony_ci<p>An object which is JSON representation of the <code>performance</code> object. It 8721cb0ef41Sopenharmony_ciis similar to <a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance/toJSON"><code>window.performance.toJSON</code></a> in browsers.</p> 8731cb0ef41Sopenharmony_ci<h5>Event: <code>'resourcetimingbufferfull'</code><span><a class="mark" href="#event-resourcetimingbufferfull" id="event-resourcetimingbufferfull">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_event_resourcetimingbufferfull"></a></h5> 8741cb0ef41Sopenharmony_ci<div class="api_metadata"> 8751cb0ef41Sopenharmony_ci<span>Added in: v18.8.0</span> 8761cb0ef41Sopenharmony_ci</div> 8771cb0ef41Sopenharmony_ci<p>The <code>'resourcetimingbufferfull'</code> event is fired when the global performance 8781cb0ef41Sopenharmony_ciresource timing buffer is full. Adjust resource timing buffer size with 8791cb0ef41Sopenharmony_ci<code>performance.setResourceTimingBufferSize()</code> or clear the buffer with 8801cb0ef41Sopenharmony_ci<code>performance.clearResourceTimings()</code> in the event listener to allow 8811cb0ef41Sopenharmony_cimore entries to be added to the performance timeline buffer.</p> 8821cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>PerformanceEntry</code><span><a class="mark" href="#class-performanceentry" id="class-performanceentry">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_performanceentry"></a></h3> 8831cb0ef41Sopenharmony_ci<div class="api_metadata"> 8841cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 8851cb0ef41Sopenharmony_ci</div> 8861cb0ef41Sopenharmony_ci<h4><code>performanceEntry.detail</code><span><a class="mark" href="#performanceentrydetail" id="performanceentrydetail">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_detail"></a></h4> 8871cb0ef41Sopenharmony_ci<div class="api_metadata"> 8881cb0ef41Sopenharmony_ci<span>Added in: v16.0.0</span> 8891cb0ef41Sopenharmony_ci</div> 8901cb0ef41Sopenharmony_ci<ul> 8911cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types" class="type"><any></a></li> 8921cb0ef41Sopenharmony_ci</ul> 8931cb0ef41Sopenharmony_ci<p>Additional detail specific to the <code>entryType</code>.</p> 8941cb0ef41Sopenharmony_ci<h4><code>performanceEntry.duration</code><span><a class="mark" href="#performanceentryduration" id="performanceentryduration">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_duration"></a></h4> 8951cb0ef41Sopenharmony_ci<div class="api_metadata"> 8961cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 8971cb0ef41Sopenharmony_ci</div> 8981cb0ef41Sopenharmony_ci<ul> 8991cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 9001cb0ef41Sopenharmony_ci</ul> 9011cb0ef41Sopenharmony_ci<p>The total number of milliseconds elapsed for this entry. This value will not 9021cb0ef41Sopenharmony_cibe meaningful for all Performance Entry types.</p> 9031cb0ef41Sopenharmony_ci<h4><code>performanceEntry.entryType</code><span><a class="mark" href="#performanceentryentrytype" id="performanceentryentrytype">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_entrytype"></a></h4> 9041cb0ef41Sopenharmony_ci<div class="api_metadata"> 9051cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 9061cb0ef41Sopenharmony_ci</div> 9071cb0ef41Sopenharmony_ci<ul> 9081cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 9091cb0ef41Sopenharmony_ci</ul> 9101cb0ef41Sopenharmony_ci<p>The type of the performance entry. It may be one of:</p> 9111cb0ef41Sopenharmony_ci<ul> 9121cb0ef41Sopenharmony_ci<li><code>'node'</code> (Node.js only)</li> 9131cb0ef41Sopenharmony_ci<li><code>'mark'</code> (available on the Web)</li> 9141cb0ef41Sopenharmony_ci<li><code>'measure'</code> (available on the Web)</li> 9151cb0ef41Sopenharmony_ci<li><code>'gc'</code> (Node.js only)</li> 9161cb0ef41Sopenharmony_ci<li><code>'function'</code> (Node.js only)</li> 9171cb0ef41Sopenharmony_ci<li><code>'http2'</code> (Node.js only)</li> 9181cb0ef41Sopenharmony_ci<li><code>'http'</code> (Node.js only)</li> 9191cb0ef41Sopenharmony_ci</ul> 9201cb0ef41Sopenharmony_ci<h4><code>performanceEntry.flags</code><span><a class="mark" href="#performanceentryflags" id="performanceentryflags">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_flags"></a></h4> 9211cb0ef41Sopenharmony_ci<div class="api_metadata"> 9221cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 9231cb0ef41Sopenharmony_ci<table> 9241cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 9251cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 9261cb0ef41Sopenharmony_ci<td><p>Runtime deprecated. Now moved to the detail property when entryType is 'gc'.</p></td></tr> 9271cb0ef41Sopenharmony_ci<tr><td>v13.9.0, v12.17.0</td> 9281cb0ef41Sopenharmony_ci<td><p><span>Added in: v13.9.0, v12.17.0</span></p></td></tr> 9291cb0ef41Sopenharmony_ci</tbody></table> 9301cb0ef41Sopenharmony_ci</details> 9311cb0ef41Sopenharmony_ci</div> 9321cb0ef41Sopenharmony_ci<ul> 9331cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 9341cb0ef41Sopenharmony_ci</ul> 9351cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 9361cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.entryType</code> is equal to <code>'gc'</code>, the <code>performance.flags</code> 9371cb0ef41Sopenharmony_ciproperty contains additional information about garbage collection operation. 9381cb0ef41Sopenharmony_ciThe value may be one of:</p> 9391cb0ef41Sopenharmony_ci<ul> 9401cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_NO</code></li> 9411cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED</code></li> 9421cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_FORCED</code></li> 9431cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING</code></li> 9441cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE</code></li> 9451cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY</code></li> 9461cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE</code></li> 9471cb0ef41Sopenharmony_ci</ul> 9481cb0ef41Sopenharmony_ci<h4><code>performanceEntry.name</code><span><a class="mark" href="#performanceentryname" id="performanceentryname">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_name"></a></h4> 9491cb0ef41Sopenharmony_ci<div class="api_metadata"> 9501cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 9511cb0ef41Sopenharmony_ci</div> 9521cb0ef41Sopenharmony_ci<ul> 9531cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 9541cb0ef41Sopenharmony_ci</ul> 9551cb0ef41Sopenharmony_ci<p>The name of the performance entry.</p> 9561cb0ef41Sopenharmony_ci<h4><code>performanceEntry.kind</code><span><a class="mark" href="#performanceentrykind" id="performanceentrykind">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_kind"></a></h4> 9571cb0ef41Sopenharmony_ci<div class="api_metadata"> 9581cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 9591cb0ef41Sopenharmony_ci<table> 9601cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 9611cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 9621cb0ef41Sopenharmony_ci<td><p>Runtime deprecated. Now moved to the detail property when entryType is 'gc'.</p></td></tr> 9631cb0ef41Sopenharmony_ci<tr><td>v8.5.0</td> 9641cb0ef41Sopenharmony_ci<td><p><span>Added in: v8.5.0</span></p></td></tr> 9651cb0ef41Sopenharmony_ci</tbody></table> 9661cb0ef41Sopenharmony_ci</details> 9671cb0ef41Sopenharmony_ci</div> 9681cb0ef41Sopenharmony_ci<ul> 9691cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 9701cb0ef41Sopenharmony_ci</ul> 9711cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 9721cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.entryType</code> is equal to <code>'gc'</code>, the <code>performance.kind</code> 9731cb0ef41Sopenharmony_ciproperty identifies the type of garbage collection operation that occurred. 9741cb0ef41Sopenharmony_ciThe value may be one of:</p> 9751cb0ef41Sopenharmony_ci<ul> 9761cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR</code></li> 9771cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR</code></li> 9781cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL</code></li> 9791cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB</code></li> 9801cb0ef41Sopenharmony_ci</ul> 9811cb0ef41Sopenharmony_ci<h4><code>performanceEntry.startTime</code><span><a class="mark" href="#performanceentrystarttime" id="performanceentrystarttime">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceentry_starttime"></a></h4> 9821cb0ef41Sopenharmony_ci<div class="api_metadata"> 9831cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 9841cb0ef41Sopenharmony_ci</div> 9851cb0ef41Sopenharmony_ci<ul> 9861cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 9871cb0ef41Sopenharmony_ci</ul> 9881cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp marking the starting time of the 9891cb0ef41Sopenharmony_ciPerformance Entry.</p> 9901cb0ef41Sopenharmony_ci<h4>Garbage Collection ('gc') Details<span><a class="mark" href="#garbage-collection-gc-details" id="garbage-collection-gc-details">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_garbage_collection_gc_details"></a></h4> 9911cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.type</code> is equal to <code>'gc'</code>, the <code>performanceEntry.detail</code> 9921cb0ef41Sopenharmony_ciproperty will be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> with two properties:</p> 9931cb0ef41Sopenharmony_ci<ul> 9941cb0ef41Sopenharmony_ci<li><code>kind</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> One of: 9951cb0ef41Sopenharmony_ci<ul> 9961cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR</code></li> 9971cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR</code></li> 9981cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_INCREMENTAL</code></li> 9991cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_WEAKCB</code></li> 10001cb0ef41Sopenharmony_ci</ul> 10011cb0ef41Sopenharmony_ci</li> 10021cb0ef41Sopenharmony_ci<li><code>flags</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> One of: 10031cb0ef41Sopenharmony_ci<ul> 10041cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_NO</code></li> 10051cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED</code></li> 10061cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_FORCED</code></li> 10071cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING</code></li> 10081cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE</code></li> 10091cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY</code></li> 10101cb0ef41Sopenharmony_ci<li><code>perf_hooks.constants.NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE</code></li> 10111cb0ef41Sopenharmony_ci</ul> 10121cb0ef41Sopenharmony_ci</li> 10131cb0ef41Sopenharmony_ci</ul> 10141cb0ef41Sopenharmony_ci<h4>HTTP ('http') Details<span><a class="mark" href="#http-http-details" id="http-http-details">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_http_http_details"></a></h4> 10151cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.type</code> is equal to <code>'http'</code>, the <code>performanceEntry.detail</code> 10161cb0ef41Sopenharmony_ciproperty will be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing additional information.</p> 10171cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>HttpClient</code>, the <code>detail</code> 10181cb0ef41Sopenharmony_ciwill contain the following properties: <code>req</code>, <code>res</code>. And the <code>req</code> property 10191cb0ef41Sopenharmony_ciwill be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing <code>method</code>, <code>url</code>, <code>headers</code>, the <code>res</code> property 10201cb0ef41Sopenharmony_ciwill be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing <code>statusCode</code>, <code>statusMessage</code>, <code>headers</code>.</p> 10211cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>HttpRequest</code>, the <code>detail</code> 10221cb0ef41Sopenharmony_ciwill contain the following properties: <code>req</code>, <code>res</code>. And the <code>req</code> property 10231cb0ef41Sopenharmony_ciwill be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing <code>method</code>, <code>url</code>, <code>headers</code>, the <code>res</code> property 10241cb0ef41Sopenharmony_ciwill be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing <code>statusCode</code>, <code>statusMessage</code>, <code>headers</code>.</p> 10251cb0ef41Sopenharmony_ci<p>This could add additional memory overhead and should only be used for 10261cb0ef41Sopenharmony_cidiagnostic purposes, not left turned on in production by default.</p> 10271cb0ef41Sopenharmony_ci<h4>HTTP/2 ('http2') Details<span><a class="mark" href="#http2-http2-details" id="http2-http2-details">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_http_2_http2_details"></a></h4> 10281cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.type</code> is equal to <code>'http2'</code>, the 10291cb0ef41Sopenharmony_ci<code>performanceEntry.detail</code> property will be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing 10301cb0ef41Sopenharmony_ciadditional performance information.</p> 10311cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>Http2Stream</code>, the <code>detail</code> 10321cb0ef41Sopenharmony_ciwill contain the following properties:</p> 10331cb0ef41Sopenharmony_ci<ul> 10341cb0ef41Sopenharmony_ci<li><code>bytesRead</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of <code>DATA</code> frame bytes received for this 10351cb0ef41Sopenharmony_ci<code>Http2Stream</code>.</li> 10361cb0ef41Sopenharmony_ci<li><code>bytesWritten</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of <code>DATA</code> frame bytes sent for this 10371cb0ef41Sopenharmony_ci<code>Http2Stream</code>.</li> 10381cb0ef41Sopenharmony_ci<li><code>id</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The identifier of the associated <code>Http2Stream</code></li> 10391cb0ef41Sopenharmony_ci<li><code>timeToFirstByte</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of milliseconds elapsed between the 10401cb0ef41Sopenharmony_ci<code>PerformanceEntry</code> <code>startTime</code> and the reception of the first <code>DATA</code> frame.</li> 10411cb0ef41Sopenharmony_ci<li><code>timeToFirstByteSent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of milliseconds elapsed between 10421cb0ef41Sopenharmony_cithe <code>PerformanceEntry</code> <code>startTime</code> and sending of the first <code>DATA</code> frame.</li> 10431cb0ef41Sopenharmony_ci<li><code>timeToFirstHeader</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of milliseconds elapsed between the 10441cb0ef41Sopenharmony_ci<code>PerformanceEntry</code> <code>startTime</code> and the reception of the first header.</li> 10451cb0ef41Sopenharmony_ci</ul> 10461cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>Http2Session</code>, the <code>detail</code> will 10471cb0ef41Sopenharmony_cicontain the following properties:</p> 10481cb0ef41Sopenharmony_ci<ul> 10491cb0ef41Sopenharmony_ci<li><code>bytesRead</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of bytes received for this <code>Http2Session</code>.</li> 10501cb0ef41Sopenharmony_ci<li><code>bytesWritten</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of bytes sent for this <code>Http2Session</code>.</li> 10511cb0ef41Sopenharmony_ci<li><code>framesReceived</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of HTTP/2 frames received by the 10521cb0ef41Sopenharmony_ci<code>Http2Session</code>.</li> 10531cb0ef41Sopenharmony_ci<li><code>framesSent</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of HTTP/2 frames sent by the <code>Http2Session</code>.</li> 10541cb0ef41Sopenharmony_ci<li><code>maxConcurrentStreams</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The maximum number of streams concurrently 10551cb0ef41Sopenharmony_ciopen during the lifetime of the <code>Http2Session</code>.</li> 10561cb0ef41Sopenharmony_ci<li><code>pingRTT</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of milliseconds elapsed since the transmission 10571cb0ef41Sopenharmony_ciof a <code>PING</code> frame and the reception of its acknowledgment. Only present if 10581cb0ef41Sopenharmony_cia <code>PING</code> frame has been sent on the <code>Http2Session</code>.</li> 10591cb0ef41Sopenharmony_ci<li><code>streamAverageDuration</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The average duration (in milliseconds) for 10601cb0ef41Sopenharmony_ciall <code>Http2Stream</code> instances.</li> 10611cb0ef41Sopenharmony_ci<li><code>streamCount</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of <code>Http2Stream</code> instances processed by 10621cb0ef41Sopenharmony_cithe <code>Http2Session</code>.</li> 10631cb0ef41Sopenharmony_ci<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> Either <code>'server'</code> or <code>'client'</code> to identify the type of 10641cb0ef41Sopenharmony_ci<code>Http2Session</code>.</li> 10651cb0ef41Sopenharmony_ci</ul> 10661cb0ef41Sopenharmony_ci<h4>Timerify ('function') Details<span><a class="mark" href="#timerify-function-details" id="timerify-function-details">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_timerify_function_details"></a></h4> 10671cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.type</code> is equal to <code>'function'</code>, the 10681cb0ef41Sopenharmony_ci<code>performanceEntry.detail</code> property will be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array" class="type"><Array></a> listing 10691cb0ef41Sopenharmony_cithe input arguments to the timed function.</p> 10701cb0ef41Sopenharmony_ci<h4>Net ('net') Details<span><a class="mark" href="#net-net-details" id="net-net-details">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_net_net_details"></a></h4> 10711cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.type</code> is equal to <code>'net'</code>, the 10721cb0ef41Sopenharmony_ci<code>performanceEntry.detail</code> property will be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing 10731cb0ef41Sopenharmony_ciadditional information.</p> 10741cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>connect</code>, the <code>detail</code> 10751cb0ef41Sopenharmony_ciwill contain the following properties: <code>host</code>, <code>port</code>.</p> 10761cb0ef41Sopenharmony_ci<h4>DNS ('dns') Details<span><a class="mark" href="#dns-dns-details" id="dns-dns-details">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_dns_dns_details"></a></h4> 10771cb0ef41Sopenharmony_ci<p>When <code>performanceEntry.type</code> is equal to <code>'dns'</code>, the 10781cb0ef41Sopenharmony_ci<code>performanceEntry.detail</code> property will be an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> containing 10791cb0ef41Sopenharmony_ciadditional information.</p> 10801cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>lookup</code>, the <code>detail</code> 10811cb0ef41Sopenharmony_ciwill contain the following properties: <code>hostname</code>, <code>family</code>, <code>hints</code>, <code>verbatim</code>, 10821cb0ef41Sopenharmony_ci<code>addresses</code>.</p> 10831cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>lookupService</code>, the <code>detail</code> will 10841cb0ef41Sopenharmony_cicontain the following properties: <code>host</code>, <code>port</code>, <code>hostname</code>, <code>service</code>.</p> 10851cb0ef41Sopenharmony_ci<p>If <code>performanceEntry.name</code> is equal to <code>queryxxx</code> or <code>getHostByAddr</code>, the <code>detail</code> will 10861cb0ef41Sopenharmony_cicontain the following properties: <code>host</code>, <code>ttl</code>, <code>result</code>. The value of <code>result</code> is 10871cb0ef41Sopenharmony_cisame as the result of <code>queryxxx</code> or <code>getHostByAddr</code>.</p> 10881cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>PerformanceNodeTiming</code><span><a class="mark" href="#class-performancenodetiming" id="class-performancenodetiming">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_performancenodetiming"></a></h3> 10891cb0ef41Sopenharmony_ci<div class="api_metadata"> 10901cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 10911cb0ef41Sopenharmony_ci</div> 10921cb0ef41Sopenharmony_ci<ul> 10931cb0ef41Sopenharmony_ci<li>Extends: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry></a></li> 10941cb0ef41Sopenharmony_ci</ul> 10951cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 10961cb0ef41Sopenharmony_ci<p>Provides timing details for Node.js itself. The constructor of this class 10971cb0ef41Sopenharmony_ciis not exposed to users.</p> 10981cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.bootstrapComplete</code><span><a class="mark" href="#performancenodetimingbootstrapcomplete" id="performancenodetimingbootstrapcomplete">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_bootstrapcomplete"></a></h4> 10991cb0ef41Sopenharmony_ci<div class="api_metadata"> 11001cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 11011cb0ef41Sopenharmony_ci</div> 11021cb0ef41Sopenharmony_ci<ul> 11031cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11041cb0ef41Sopenharmony_ci</ul> 11051cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at which the Node.js process 11061cb0ef41Sopenharmony_cicompleted bootstrapping. If bootstrapping has not yet finished, the property 11071cb0ef41Sopenharmony_cihas the value of -1.</p> 11081cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.environment</code><span><a class="mark" href="#performancenodetimingenvironment" id="performancenodetimingenvironment">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_environment"></a></h4> 11091cb0ef41Sopenharmony_ci<div class="api_metadata"> 11101cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 11111cb0ef41Sopenharmony_ci</div> 11121cb0ef41Sopenharmony_ci<ul> 11131cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11141cb0ef41Sopenharmony_ci</ul> 11151cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at which the Node.js environment was 11161cb0ef41Sopenharmony_ciinitialized.</p> 11171cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.idleTime</code><span><a class="mark" href="#performancenodetimingidletime" id="performancenodetimingidletime">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_idletime"></a></h4> 11181cb0ef41Sopenharmony_ci<div class="api_metadata"> 11191cb0ef41Sopenharmony_ci<span>Added in: v14.10.0, v12.19.0</span> 11201cb0ef41Sopenharmony_ci</div> 11211cb0ef41Sopenharmony_ci<ul> 11221cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11231cb0ef41Sopenharmony_ci</ul> 11241cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp of the amount of time the event loop 11251cb0ef41Sopenharmony_cihas been idle within the event loop's event provider (e.g. <code>epoll_wait</code>). This 11261cb0ef41Sopenharmony_cidoes not take CPU usage into consideration. If the event loop has not yet 11271cb0ef41Sopenharmony_cistarted (e.g., in the first tick of the main script), the property has the 11281cb0ef41Sopenharmony_civalue of 0.</p> 11291cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.loopExit</code><span><a class="mark" href="#performancenodetimingloopexit" id="performancenodetimingloopexit">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_loopexit"></a></h4> 11301cb0ef41Sopenharmony_ci<div class="api_metadata"> 11311cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 11321cb0ef41Sopenharmony_ci</div> 11331cb0ef41Sopenharmony_ci<ul> 11341cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11351cb0ef41Sopenharmony_ci</ul> 11361cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at which the Node.js event loop 11371cb0ef41Sopenharmony_ciexited. If the event loop has not yet exited, the property has the value of -1. 11381cb0ef41Sopenharmony_ciIt can only have a value of not -1 in a handler of the <a href="process.html#event-exit"><code>'exit'</code></a> event.</p> 11391cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.loopStart</code><span><a class="mark" href="#performancenodetimingloopstart" id="performancenodetimingloopstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_loopstart"></a></h4> 11401cb0ef41Sopenharmony_ci<div class="api_metadata"> 11411cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 11421cb0ef41Sopenharmony_ci</div> 11431cb0ef41Sopenharmony_ci<ul> 11441cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11451cb0ef41Sopenharmony_ci</ul> 11461cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at which the Node.js event loop 11471cb0ef41Sopenharmony_cistarted. If the event loop has not yet started (e.g., in the first tick of the 11481cb0ef41Sopenharmony_cimain script), the property has the value of -1.</p> 11491cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.nodeStart</code><span><a class="mark" href="#performancenodetimingnodestart" id="performancenodetimingnodestart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_nodestart"></a></h4> 11501cb0ef41Sopenharmony_ci<div class="api_metadata"> 11511cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 11521cb0ef41Sopenharmony_ci</div> 11531cb0ef41Sopenharmony_ci<ul> 11541cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11551cb0ef41Sopenharmony_ci</ul> 11561cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at which the Node.js process was 11571cb0ef41Sopenharmony_ciinitialized.</p> 11581cb0ef41Sopenharmony_ci<h4><code>performanceNodeTiming.v8Start</code><span><a class="mark" href="#performancenodetimingv8start" id="performancenodetimingv8start">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performancenodetiming_v8start"></a></h4> 11591cb0ef41Sopenharmony_ci<div class="api_metadata"> 11601cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 11611cb0ef41Sopenharmony_ci</div> 11621cb0ef41Sopenharmony_ci<ul> 11631cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11641cb0ef41Sopenharmony_ci</ul> 11651cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at which the V8 platform was 11661cb0ef41Sopenharmony_ciinitialized.</p> 11671cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>PerformanceResourceTiming</code><span><a class="mark" href="#class-performanceresourcetiming" id="class-performanceresourcetiming">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_performanceresourcetiming"></a></h3> 11681cb0ef41Sopenharmony_ci<div class="api_metadata"> 11691cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 11701cb0ef41Sopenharmony_ci</div> 11711cb0ef41Sopenharmony_ci<ul> 11721cb0ef41Sopenharmony_ci<li>Extends: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry></a></li> 11731cb0ef41Sopenharmony_ci</ul> 11741cb0ef41Sopenharmony_ci<p>Provides detailed network timing data regarding the loading of an application's 11751cb0ef41Sopenharmony_ciresources.</p> 11761cb0ef41Sopenharmony_ci<p>The constructor of this class is not exposed to users directly.</p> 11771cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.workerStart</code><span><a class="mark" href="#performanceresourcetimingworkerstart" id="performanceresourcetimingworkerstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_workerstart"></a></h4> 11781cb0ef41Sopenharmony_ci<div class="api_metadata"> 11791cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 11801cb0ef41Sopenharmony_ci</div> 11811cb0ef41Sopenharmony_ci<ul> 11821cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11831cb0ef41Sopenharmony_ci</ul> 11841cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp at immediately before dispatching 11851cb0ef41Sopenharmony_cithe <code>fetch</code> request. If the resource is not intercepted by a worker the property 11861cb0ef41Sopenharmony_ciwill always return 0.</p> 11871cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.redirectStart</code><span><a class="mark" href="#performanceresourcetimingredirectstart" id="performanceresourcetimingredirectstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_redirectstart"></a></h4> 11881cb0ef41Sopenharmony_ci<div class="api_metadata"> 11891cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 11901cb0ef41Sopenharmony_ci</div> 11911cb0ef41Sopenharmony_ci<ul> 11921cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 11931cb0ef41Sopenharmony_ci</ul> 11941cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp that represents the start time 11951cb0ef41Sopenharmony_ciof the fetch which initiates the redirect.</p> 11961cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.redirectEnd</code><span><a class="mark" href="#performanceresourcetimingredirectend" id="performanceresourcetimingredirectend">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_redirectend"></a></h4> 11971cb0ef41Sopenharmony_ci<div class="api_metadata"> 11981cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 11991cb0ef41Sopenharmony_ci</div> 12001cb0ef41Sopenharmony_ci<ul> 12011cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12021cb0ef41Sopenharmony_ci</ul> 12031cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp that will be created immediately after 12041cb0ef41Sopenharmony_cireceiving the last byte of the response of the last redirect.</p> 12051cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.fetchStart</code><span><a class="mark" href="#performanceresourcetimingfetchstart" id="performanceresourcetimingfetchstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_fetchstart"></a></h4> 12061cb0ef41Sopenharmony_ci<div class="api_metadata"> 12071cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12081cb0ef41Sopenharmony_ci</div> 12091cb0ef41Sopenharmony_ci<ul> 12101cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12111cb0ef41Sopenharmony_ci</ul> 12121cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp immediately before the Node.js starts 12131cb0ef41Sopenharmony_cito fetch the resource.</p> 12141cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.domainLookupStart</code><span><a class="mark" href="#performanceresourcetimingdomainlookupstart" id="performanceresourcetimingdomainlookupstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_domainlookupstart"></a></h4> 12151cb0ef41Sopenharmony_ci<div class="api_metadata"> 12161cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12171cb0ef41Sopenharmony_ci</div> 12181cb0ef41Sopenharmony_ci<ul> 12191cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12201cb0ef41Sopenharmony_ci</ul> 12211cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp immediately before the Node.js starts 12221cb0ef41Sopenharmony_cithe domain name lookup for the resource.</p> 12231cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.domainLookupEnd</code><span><a class="mark" href="#performanceresourcetimingdomainlookupend" id="performanceresourcetimingdomainlookupend">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_domainlookupend"></a></h4> 12241cb0ef41Sopenharmony_ci<div class="api_metadata"> 12251cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12261cb0ef41Sopenharmony_ci</div> 12271cb0ef41Sopenharmony_ci<ul> 12281cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12291cb0ef41Sopenharmony_ci</ul> 12301cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp representing the time immediately 12311cb0ef41Sopenharmony_ciafter the Node.js finished the domain name lookup for the resource.</p> 12321cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.connectStart</code><span><a class="mark" href="#performanceresourcetimingconnectstart" id="performanceresourcetimingconnectstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_connectstart"></a></h4> 12331cb0ef41Sopenharmony_ci<div class="api_metadata"> 12341cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12351cb0ef41Sopenharmony_ci</div> 12361cb0ef41Sopenharmony_ci<ul> 12371cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12381cb0ef41Sopenharmony_ci</ul> 12391cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp representing the time immediately 12401cb0ef41Sopenharmony_cibefore Node.js starts to establish the connection to the server to retrieve 12411cb0ef41Sopenharmony_cithe resource.</p> 12421cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.connectEnd</code><span><a class="mark" href="#performanceresourcetimingconnectend" id="performanceresourcetimingconnectend">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_connectend"></a></h4> 12431cb0ef41Sopenharmony_ci<div class="api_metadata"> 12441cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12451cb0ef41Sopenharmony_ci</div> 12461cb0ef41Sopenharmony_ci<ul> 12471cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12481cb0ef41Sopenharmony_ci</ul> 12491cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp representing the time immediately 12501cb0ef41Sopenharmony_ciafter Node.js finishes establishing the connection to the server to retrieve 12511cb0ef41Sopenharmony_cithe resource.</p> 12521cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.secureConnectionStart</code><span><a class="mark" href="#performanceresourcetimingsecureconnectionstart" id="performanceresourcetimingsecureconnectionstart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_secureconnectionstart"></a></h4> 12531cb0ef41Sopenharmony_ci<div class="api_metadata"> 12541cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12551cb0ef41Sopenharmony_ci</div> 12561cb0ef41Sopenharmony_ci<ul> 12571cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12581cb0ef41Sopenharmony_ci</ul> 12591cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp representing the time immediately 12601cb0ef41Sopenharmony_cibefore Node.js starts the handshake process to secure the current connection.</p> 12611cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.requestStart</code><span><a class="mark" href="#performanceresourcetimingrequeststart" id="performanceresourcetimingrequeststart">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_requeststart"></a></h4> 12621cb0ef41Sopenharmony_ci<div class="api_metadata"> 12631cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12641cb0ef41Sopenharmony_ci</div> 12651cb0ef41Sopenharmony_ci<ul> 12661cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12671cb0ef41Sopenharmony_ci</ul> 12681cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp representing the time immediately 12691cb0ef41Sopenharmony_cibefore Node.js receives the first byte of the response from the server.</p> 12701cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.responseEnd</code><span><a class="mark" href="#performanceresourcetimingresponseend" id="performanceresourcetimingresponseend">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_responseend"></a></h4> 12711cb0ef41Sopenharmony_ci<div class="api_metadata"> 12721cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12731cb0ef41Sopenharmony_ci</div> 12741cb0ef41Sopenharmony_ci<ul> 12751cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12761cb0ef41Sopenharmony_ci</ul> 12771cb0ef41Sopenharmony_ci<p>The high resolution millisecond timestamp representing the time immediately 12781cb0ef41Sopenharmony_ciafter Node.js receives the last byte of the resource or immediately before 12791cb0ef41Sopenharmony_cithe transport connection is closed, whichever comes first.</p> 12801cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.transferSize</code><span><a class="mark" href="#performanceresourcetimingtransfersize" id="performanceresourcetimingtransfersize">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_transfersize"></a></h4> 12811cb0ef41Sopenharmony_ci<div class="api_metadata"> 12821cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12831cb0ef41Sopenharmony_ci</div> 12841cb0ef41Sopenharmony_ci<ul> 12851cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12861cb0ef41Sopenharmony_ci</ul> 12871cb0ef41Sopenharmony_ci<p>A number representing the size (in octets) of the fetched resource. The size 12881cb0ef41Sopenharmony_ciincludes the response header fields plus the response payload body.</p> 12891cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.encodedBodySize</code><span><a class="mark" href="#performanceresourcetimingencodedbodysize" id="performanceresourcetimingencodedbodysize">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_encodedbodysize"></a></h4> 12901cb0ef41Sopenharmony_ci<div class="api_metadata"> 12911cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 12921cb0ef41Sopenharmony_ci</div> 12931cb0ef41Sopenharmony_ci<ul> 12941cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 12951cb0ef41Sopenharmony_ci</ul> 12961cb0ef41Sopenharmony_ci<p>A number representing the size (in octets) received from the fetch 12971cb0ef41Sopenharmony_ci(HTTP or cache), of the payload body, before removing any applied 12981cb0ef41Sopenharmony_cicontent-codings.</p> 12991cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.decodedBodySize</code><span><a class="mark" href="#performanceresourcetimingdecodedbodysize" id="performanceresourcetimingdecodedbodysize">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_decodedbodysize"></a></h4> 13001cb0ef41Sopenharmony_ci<div class="api_metadata"> 13011cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 13021cb0ef41Sopenharmony_ci</div> 13031cb0ef41Sopenharmony_ci<ul> 13041cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 13051cb0ef41Sopenharmony_ci</ul> 13061cb0ef41Sopenharmony_ci<p>A number representing the size (in octets) received from the fetch 13071cb0ef41Sopenharmony_ci(HTTP or cache), of the message body, after removing any applied 13081cb0ef41Sopenharmony_cicontent-codings.</p> 13091cb0ef41Sopenharmony_ci<h4><code>performanceResourceTiming.toJSON()</code><span><a class="mark" href="#performanceresourcetimingtojson" id="performanceresourcetimingtojson">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceresourcetiming_tojson"></a></h4> 13101cb0ef41Sopenharmony_ci<div class="api_metadata"> 13111cb0ef41Sopenharmony_ci<span>Added in: v18.2.0</span> 13121cb0ef41Sopenharmony_ci</div> 13131cb0ef41Sopenharmony_ci<p>Returns a <code>object</code> that is the JSON representation of the 13141cb0ef41Sopenharmony_ci<code>PerformanceResourceTiming</code> object</p> 13151cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>perf_hooks.PerformanceObserver</code><span><a class="mark" href="#class-perf_hooksperformanceobserver" id="class-perf_hooksperformanceobserver">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_perf_hooks_performanceobserver"></a></h3> 13161cb0ef41Sopenharmony_ci<div class="api_metadata"> 13171cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 13181cb0ef41Sopenharmony_ci</div> 13191cb0ef41Sopenharmony_ci<h4><code>PerformanceObserver.supportedEntryTypes</code><span><a class="mark" href="#performanceobserversupportedentrytypes" id="performanceobserversupportedentrytypes">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceobserver_supportedentrytypes"></a></h4> 13201cb0ef41Sopenharmony_ci<div class="api_metadata"> 13211cb0ef41Sopenharmony_ci<span>Added in: v16.0.0</span> 13221cb0ef41Sopenharmony_ci</div> 13231cb0ef41Sopenharmony_ci<ul> 13241cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a></li> 13251cb0ef41Sopenharmony_ci</ul> 13261cb0ef41Sopenharmony_ci<p>Get supported types.</p> 13271cb0ef41Sopenharmony_ci<h4><code>new PerformanceObserver(callback)</code><span><a class="mark" href="#new-performanceobservercallback" id="new-performanceobservercallback">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_new_performanceobserver_callback"></a></h4> 13281cb0ef41Sopenharmony_ci<div class="api_metadata"> 13291cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 13301cb0ef41Sopenharmony_ci<table> 13311cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 13321cb0ef41Sopenharmony_ci<tr><td>v18.0.0</td> 13331cb0ef41Sopenharmony_ci<td><p>Passing an invalid callback to the <code>callback</code> argument now throws <code>ERR_INVALID_ARG_TYPE</code> instead of <code>ERR_INVALID_CALLBACK</code>.</p></td></tr> 13341cb0ef41Sopenharmony_ci<tr><td>v8.5.0</td> 13351cb0ef41Sopenharmony_ci<td><p><span>Added in: v8.5.0</span></p></td></tr> 13361cb0ef41Sopenharmony_ci</tbody></table> 13371cb0ef41Sopenharmony_ci</details> 13381cb0ef41Sopenharmony_ci</div> 13391cb0ef41Sopenharmony_ci<ul> 13401cb0ef41Sopenharmony_ci<li><code>callback</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function" class="type"><Function></a> 13411cb0ef41Sopenharmony_ci<ul> 13421cb0ef41Sopenharmony_ci<li><code>list</code> <a href="perf_hooks.html#class-performanceobserverentrylist" class="type"><PerformanceObserverEntryList></a></li> 13431cb0ef41Sopenharmony_ci<li><code>observer</code> <a href="perf_hooks.html#class-perf_hooksperformanceobserver" class="type"><PerformanceObserver></a></li> 13441cb0ef41Sopenharmony_ci</ul> 13451cb0ef41Sopenharmony_ci</li> 13461cb0ef41Sopenharmony_ci</ul> 13471cb0ef41Sopenharmony_ci<p><code>PerformanceObserver</code> objects provide notifications when new 13481cb0ef41Sopenharmony_ci<code>PerformanceEntry</code> instances have been added to the Performance Timeline.</p> 13491cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { 13501cb0ef41Sopenharmony_ci performance, 13511cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 13521cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 13531cb0ef41Sopenharmony_ci 13541cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">list, observer</span>) =></span> { 13551cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(list.<span class="hljs-title function_">getEntries</span>()); 13561cb0ef41Sopenharmony_ci 13571cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 13581cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 13591cb0ef41Sopenharmony_ci observer.<span class="hljs-title function_">disconnect</span>(); 13601cb0ef41Sopenharmony_ci}); 13611cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'mark'</span>], <span class="hljs-attr">buffered</span>: <span class="hljs-literal">true</span> }); 13621cb0ef41Sopenharmony_ci 13631cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'test'</span>);</code> <button class="copy-button">copy</button></pre> 13641cb0ef41Sopenharmony_ci<p>Because <code>PerformanceObserver</code> instances introduce their own additional 13651cb0ef41Sopenharmony_ciperformance overhead, instances should not be left subscribed to notifications 13661cb0ef41Sopenharmony_ciindefinitely. Users should disconnect observers as soon as they are no 13671cb0ef41Sopenharmony_cilonger needed.</p> 13681cb0ef41Sopenharmony_ci<p>The <code>callback</code> is invoked when a <code>PerformanceObserver</code> is 13691cb0ef41Sopenharmony_cinotified about new <code>PerformanceEntry</code> instances. The callback receives a 13701cb0ef41Sopenharmony_ci<code>PerformanceObserverEntryList</code> instance and a reference to the 13711cb0ef41Sopenharmony_ci<code>PerformanceObserver</code>.</p> 13721cb0ef41Sopenharmony_ci<h4><code>performanceObserver.disconnect()</code><span><a class="mark" href="#performanceobserverdisconnect" id="performanceobserverdisconnect">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceobserver_disconnect"></a></h4> 13731cb0ef41Sopenharmony_ci<div class="api_metadata"> 13741cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 13751cb0ef41Sopenharmony_ci</div> 13761cb0ef41Sopenharmony_ci<p>Disconnects the <code>PerformanceObserver</code> instance from all notifications.</p> 13771cb0ef41Sopenharmony_ci<h4><code>performanceObserver.observe(options)</code><span><a class="mark" href="#performanceobserverobserveoptions" id="performanceobserverobserveoptions">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceobserver_observe_options"></a></h4> 13781cb0ef41Sopenharmony_ci<div class="api_metadata"> 13791cb0ef41Sopenharmony_ci<details class="changelog"><summary>History</summary> 13801cb0ef41Sopenharmony_ci<table> 13811cb0ef41Sopenharmony_ci<tbody><tr><th>Version</th><th>Changes</th></tr> 13821cb0ef41Sopenharmony_ci<tr><td>v16.7.0</td> 13831cb0ef41Sopenharmony_ci<td><p>Updated to conform to Performance Timeline Level 2. The buffered option has been added back.</p></td></tr> 13841cb0ef41Sopenharmony_ci<tr><td>v16.0.0</td> 13851cb0ef41Sopenharmony_ci<td><p>Updated to conform to User Timing Level 3. The buffered option has been removed.</p></td></tr> 13861cb0ef41Sopenharmony_ci<tr><td>v8.5.0</td> 13871cb0ef41Sopenharmony_ci<td><p><span>Added in: v8.5.0</span></p></td></tr> 13881cb0ef41Sopenharmony_ci</tbody></table> 13891cb0ef41Sopenharmony_ci</details> 13901cb0ef41Sopenharmony_ci</div> 13911cb0ef41Sopenharmony_ci<ul> 13921cb0ef41Sopenharmony_ci<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 13931cb0ef41Sopenharmony_ci<ul> 13941cb0ef41Sopenharmony_ci<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a> A single <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry></a> type. Must not be given 13951cb0ef41Sopenharmony_ciif <code>entryTypes</code> is already specified.</li> 13961cb0ef41Sopenharmony_ci<li><code>entryTypes</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string[]></a> An array of strings identifying the types of 13971cb0ef41Sopenharmony_ci<a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry></a> instances the observer is interested in. If not 13981cb0ef41Sopenharmony_ciprovided an error will be thrown.</li> 13991cb0ef41Sopenharmony_ci<li><code>buffered</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a> If true, the observer callback is called with a 14001cb0ef41Sopenharmony_cilist global <code>PerformanceEntry</code> buffered entries. If false, only 14011cb0ef41Sopenharmony_ci<code>PerformanceEntry</code>s created after the time point are sent to the 14021cb0ef41Sopenharmony_ciobserver callback. <strong>Default:</strong> <code>false</code>.</li> 14031cb0ef41Sopenharmony_ci</ul> 14041cb0ef41Sopenharmony_ci</li> 14051cb0ef41Sopenharmony_ci</ul> 14061cb0ef41Sopenharmony_ci<p>Subscribes the <a href="perf_hooks.html#class-perf_hooksperformanceobserver" class="type"><PerformanceObserver></a> instance to notifications of new 14071cb0ef41Sopenharmony_ci<a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry></a> instances identified either by <code>options.entryTypes</code> 14081cb0ef41Sopenharmony_cior <code>options.type</code>:</p> 14091cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { 14101cb0ef41Sopenharmony_ci performance, 14111cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 14121cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 14131cb0ef41Sopenharmony_ci 14141cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">list, observer</span>) =></span> { 14151cb0ef41Sopenharmony_ci <span class="hljs-comment">// Called once asynchronously. `list` contains three items.</span> 14161cb0ef41Sopenharmony_ci}); 14171cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">type</span>: <span class="hljs-string">'mark'</span> }); 14181cb0ef41Sopenharmony_ci 14191cb0ef41Sopenharmony_ci<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> n = <span class="hljs-number">0</span>; n < <span class="hljs-number">3</span>; n++) 14201cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">`test<span class="hljs-subst">${n}</span>`</span>);</code> <button class="copy-button">copy</button></pre> 14211cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>PerformanceObserverEntryList</code><span><a class="mark" href="#class-performanceobserverentrylist" id="class-performanceobserverentrylist">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_performanceobserverentrylist"></a></h3> 14221cb0ef41Sopenharmony_ci<div class="api_metadata"> 14231cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 14241cb0ef41Sopenharmony_ci</div> 14251cb0ef41Sopenharmony_ci<p>The <code>PerformanceObserverEntryList</code> class is used to provide access to the 14261cb0ef41Sopenharmony_ci<code>PerformanceEntry</code> instances passed to a <code>PerformanceObserver</code>. 14271cb0ef41Sopenharmony_ciThe constructor of this class is not exposed to users.</p> 14281cb0ef41Sopenharmony_ci<h4><code>performanceObserverEntryList.getEntries()</code><span><a class="mark" href="#performanceobserverentrylistgetentries" id="performanceobserverentrylistgetentries">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceobserverentrylist_getentries"></a></h4> 14291cb0ef41Sopenharmony_ci<div class="api_metadata"> 14301cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 14311cb0ef41Sopenharmony_ci</div> 14321cb0ef41Sopenharmony_ci<ul> 14331cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry[]></a></li> 14341cb0ef41Sopenharmony_ci</ul> 14351cb0ef41Sopenharmony_ci<p>Returns a list of <code>PerformanceEntry</code> objects in chronological order 14361cb0ef41Sopenharmony_ciwith respect to <code>performanceEntry.startTime</code>.</p> 14371cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { 14381cb0ef41Sopenharmony_ci performance, 14391cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 14401cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 14411cb0ef41Sopenharmony_ci 14421cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">perfObserverList, observer</span>) =></span> { 14431cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(perfObserverList.<span class="hljs-title function_">getEntries</span>()); 14441cb0ef41Sopenharmony_ci <span class="hljs-comment">/** 14451cb0ef41Sopenharmony_ci * [ 14461cb0ef41Sopenharmony_ci * PerformanceEntry { 14471cb0ef41Sopenharmony_ci * name: 'test', 14481cb0ef41Sopenharmony_ci * entryType: 'mark', 14491cb0ef41Sopenharmony_ci * startTime: 81.465639, 14501cb0ef41Sopenharmony_ci * duration: 0 14511cb0ef41Sopenharmony_ci * }, 14521cb0ef41Sopenharmony_ci * PerformanceEntry { 14531cb0ef41Sopenharmony_ci * name: 'meow', 14541cb0ef41Sopenharmony_ci * entryType: 'mark', 14551cb0ef41Sopenharmony_ci * startTime: 81.860064, 14561cb0ef41Sopenharmony_ci * duration: 0 14571cb0ef41Sopenharmony_ci * } 14581cb0ef41Sopenharmony_ci * ] 14591cb0ef41Sopenharmony_ci */</span> 14601cb0ef41Sopenharmony_ci 14611cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 14621cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 14631cb0ef41Sopenharmony_ci observer.<span class="hljs-title function_">disconnect</span>(); 14641cb0ef41Sopenharmony_ci}); 14651cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">type</span>: <span class="hljs-string">'mark'</span> }); 14661cb0ef41Sopenharmony_ci 14671cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'test'</span>); 14681cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'meow'</span>);</code> <button class="copy-button">copy</button></pre> 14691cb0ef41Sopenharmony_ci<h4><code>performanceObserverEntryList.getEntriesByName(name[, type])</code><span><a class="mark" href="#performanceobserverentrylistgetentriesbynamename-type" id="performanceobserverentrylistgetentriesbynamename-type">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceobserverentrylist_getentriesbyname_name_type"></a></h4> 14701cb0ef41Sopenharmony_ci<div class="api_metadata"> 14711cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 14721cb0ef41Sopenharmony_ci</div> 14731cb0ef41Sopenharmony_ci<ul> 14741cb0ef41Sopenharmony_ci<li><code>name</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 14751cb0ef41Sopenharmony_ci<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 14761cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry[]></a></li> 14771cb0ef41Sopenharmony_ci</ul> 14781cb0ef41Sopenharmony_ci<p>Returns a list of <code>PerformanceEntry</code> objects in chronological order 14791cb0ef41Sopenharmony_ciwith respect to <code>performanceEntry.startTime</code> whose <code>performanceEntry.name</code> is 14801cb0ef41Sopenharmony_ciequal to <code>name</code>, and optionally, whose <code>performanceEntry.entryType</code> is equal to 14811cb0ef41Sopenharmony_ci<code>type</code>.</p> 14821cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { 14831cb0ef41Sopenharmony_ci performance, 14841cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 14851cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 14861cb0ef41Sopenharmony_ci 14871cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">perfObserverList, observer</span>) =></span> { 14881cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(perfObserverList.<span class="hljs-title function_">getEntriesByName</span>(<span class="hljs-string">'meow'</span>)); 14891cb0ef41Sopenharmony_ci <span class="hljs-comment">/** 14901cb0ef41Sopenharmony_ci * [ 14911cb0ef41Sopenharmony_ci * PerformanceEntry { 14921cb0ef41Sopenharmony_ci * name: 'meow', 14931cb0ef41Sopenharmony_ci * entryType: 'mark', 14941cb0ef41Sopenharmony_ci * startTime: 98.545991, 14951cb0ef41Sopenharmony_ci * duration: 0 14961cb0ef41Sopenharmony_ci * } 14971cb0ef41Sopenharmony_ci * ] 14981cb0ef41Sopenharmony_ci */</span> 14991cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(perfObserverList.<span class="hljs-title function_">getEntriesByName</span>(<span class="hljs-string">'nope'</span>)); <span class="hljs-comment">// []</span> 15001cb0ef41Sopenharmony_ci 15011cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(perfObserverList.<span class="hljs-title function_">getEntriesByName</span>(<span class="hljs-string">'test'</span>, <span class="hljs-string">'mark'</span>)); 15021cb0ef41Sopenharmony_ci <span class="hljs-comment">/** 15031cb0ef41Sopenharmony_ci * [ 15041cb0ef41Sopenharmony_ci * PerformanceEntry { 15051cb0ef41Sopenharmony_ci * name: 'test', 15061cb0ef41Sopenharmony_ci * entryType: 'mark', 15071cb0ef41Sopenharmony_ci * startTime: 63.518931, 15081cb0ef41Sopenharmony_ci * duration: 0 15091cb0ef41Sopenharmony_ci * } 15101cb0ef41Sopenharmony_ci * ] 15111cb0ef41Sopenharmony_ci */</span> 15121cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(perfObserverList.<span class="hljs-title function_">getEntriesByName</span>(<span class="hljs-string">'test'</span>, <span class="hljs-string">'measure'</span>)); <span class="hljs-comment">// []</span> 15131cb0ef41Sopenharmony_ci 15141cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 15151cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 15161cb0ef41Sopenharmony_ci observer.<span class="hljs-title function_">disconnect</span>(); 15171cb0ef41Sopenharmony_ci}); 15181cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'mark'</span>, <span class="hljs-string">'measure'</span>] }); 15191cb0ef41Sopenharmony_ci 15201cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'test'</span>); 15211cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'meow'</span>);</code> <button class="copy-button">copy</button></pre> 15221cb0ef41Sopenharmony_ci<h4><code>performanceObserverEntryList.getEntriesByType(type)</code><span><a class="mark" href="#performanceobserverentrylistgetentriesbytypetype" id="performanceobserverentrylistgetentriesbytypetype">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_performanceobserverentrylist_getentriesbytype_type"></a></h4> 15231cb0ef41Sopenharmony_ci<div class="api_metadata"> 15241cb0ef41Sopenharmony_ci<span>Added in: v8.5.0</span> 15251cb0ef41Sopenharmony_ci</div> 15261cb0ef41Sopenharmony_ci<ul> 15271cb0ef41Sopenharmony_ci<li><code>type</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type" class="type"><string></a></li> 15281cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-performanceentry" class="type"><PerformanceEntry[]></a></li> 15291cb0ef41Sopenharmony_ci</ul> 15301cb0ef41Sopenharmony_ci<p>Returns a list of <code>PerformanceEntry</code> objects in chronological order 15311cb0ef41Sopenharmony_ciwith respect to <code>performanceEntry.startTime</code> whose <code>performanceEntry.entryType</code> 15321cb0ef41Sopenharmony_ciis equal to <code>type</code>.</p> 15331cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { 15341cb0ef41Sopenharmony_ci performance, 15351cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 15361cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 15371cb0ef41Sopenharmony_ci 15381cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">perfObserverList, observer</span>) =></span> { 15391cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(perfObserverList.<span class="hljs-title function_">getEntriesByType</span>(<span class="hljs-string">'mark'</span>)); 15401cb0ef41Sopenharmony_ci <span class="hljs-comment">/** 15411cb0ef41Sopenharmony_ci * [ 15421cb0ef41Sopenharmony_ci * PerformanceEntry { 15431cb0ef41Sopenharmony_ci * name: 'test', 15441cb0ef41Sopenharmony_ci * entryType: 'mark', 15451cb0ef41Sopenharmony_ci * startTime: 55.897834, 15461cb0ef41Sopenharmony_ci * duration: 0 15471cb0ef41Sopenharmony_ci * }, 15481cb0ef41Sopenharmony_ci * PerformanceEntry { 15491cb0ef41Sopenharmony_ci * name: 'meow', 15501cb0ef41Sopenharmony_ci * entryType: 'mark', 15511cb0ef41Sopenharmony_ci * startTime: 56.350146, 15521cb0ef41Sopenharmony_ci * duration: 0 15531cb0ef41Sopenharmony_ci * } 15541cb0ef41Sopenharmony_ci * ] 15551cb0ef41Sopenharmony_ci */</span> 15561cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 15571cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 15581cb0ef41Sopenharmony_ci observer.<span class="hljs-title function_">disconnect</span>(); 15591cb0ef41Sopenharmony_ci}); 15601cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">type</span>: <span class="hljs-string">'mark'</span> }); 15611cb0ef41Sopenharmony_ci 15621cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'test'</span>); 15631cb0ef41Sopenharmony_ciperformance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">'meow'</span>);</code> <button class="copy-button">copy</button></pre> 15641cb0ef41Sopenharmony_ci</section><section><h3><code>perf_hooks.createHistogram([options])</code><span><a class="mark" href="#perf_hookscreatehistogramoptions" id="perf_hookscreatehistogramoptions">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_perf_hooks_createhistogram_options"></a></h3> 15651cb0ef41Sopenharmony_ci<div class="api_metadata"> 15661cb0ef41Sopenharmony_ci<span>Added in: v15.9.0, v14.18.0</span> 15671cb0ef41Sopenharmony_ci</div> 15681cb0ef41Sopenharmony_ci<ul> 15691cb0ef41Sopenharmony_ci<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 15701cb0ef41Sopenharmony_ci<ul> 15711cb0ef41Sopenharmony_ci<li><code>lowest</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a> The lowest discernible value. Must be an integer 15721cb0ef41Sopenharmony_civalue greater than 0. <strong>Default:</strong> <code>1</code>.</li> 15731cb0ef41Sopenharmony_ci<li><code>highest</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a> The highest recordable value. Must be an integer 15741cb0ef41Sopenharmony_civalue that is equal to or greater than two times <code>lowest</code>. 15751cb0ef41Sopenharmony_ci<strong>Default:</strong> <code>Number.MAX_SAFE_INTEGER</code>.</li> 15761cb0ef41Sopenharmony_ci<li><code>figures</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The number of accuracy digits. Must be a number between 15771cb0ef41Sopenharmony_ci<code>1</code> and <code>5</code>. <strong>Default:</strong> <code>3</code>.</li> 15781cb0ef41Sopenharmony_ci</ul> 15791cb0ef41Sopenharmony_ci</li> 15801cb0ef41Sopenharmony_ci<li>Returns <a href="perf_hooks.html#class-recordablehistogram-extends-histogram" class="type"><RecordableHistogram></a></li> 15811cb0ef41Sopenharmony_ci</ul> 15821cb0ef41Sopenharmony_ci<p>Returns a <a href="perf_hooks.html#class-recordablehistogram-extends-histogram" class="type"><RecordableHistogram></a>.</p> 15831cb0ef41Sopenharmony_ci</section><section><h3><code>perf_hooks.monitorEventLoopDelay([options])</code><span><a class="mark" href="#perf_hooksmonitoreventloopdelayoptions" id="perf_hooksmonitoreventloopdelayoptions">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_perf_hooks_monitoreventloopdelay_options"></a></h3> 15841cb0ef41Sopenharmony_ci<div class="api_metadata"> 15851cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 15861cb0ef41Sopenharmony_ci</div> 15871cb0ef41Sopenharmony_ci<ul> 15881cb0ef41Sopenharmony_ci<li><code>options</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object" class="type"><Object></a> 15891cb0ef41Sopenharmony_ci<ul> 15901cb0ef41Sopenharmony_ci<li><code>resolution</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> The sampling rate in milliseconds. Must be greater 15911cb0ef41Sopenharmony_cithan zero. <strong>Default:</strong> <code>10</code>.</li> 15921cb0ef41Sopenharmony_ci</ul> 15931cb0ef41Sopenharmony_ci</li> 15941cb0ef41Sopenharmony_ci<li>Returns: <a href="perf_hooks.html#class-intervalhistogram-extends-histogram" class="type"><IntervalHistogram></a></li> 15951cb0ef41Sopenharmony_ci</ul> 15961cb0ef41Sopenharmony_ci<p><em>This property is an extension by Node.js. It is not available in Web browsers.</em></p> 15971cb0ef41Sopenharmony_ci<p>Creates an <code>IntervalHistogram</code> object that samples and reports the event loop 15981cb0ef41Sopenharmony_cidelay over time. The delays will be reported in nanoseconds.</p> 15991cb0ef41Sopenharmony_ci<p>Using a timer to detect approximate event loop delay works because the 16001cb0ef41Sopenharmony_ciexecution of timers is tied specifically to the lifecycle of the libuv 16011cb0ef41Sopenharmony_cievent loop. That is, a delay in the loop will cause a delay in the execution 16021cb0ef41Sopenharmony_ciof the timer, and those delays are specifically what this API is intended to 16031cb0ef41Sopenharmony_cidetect.</p> 16041cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-keyword">const</span> { monitorEventLoopDelay } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 16051cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> h = <span class="hljs-title function_">monitorEventLoopDelay</span>({ <span class="hljs-attr">resolution</span>: <span class="hljs-number">20</span> }); 16061cb0ef41Sopenharmony_cih.<span class="hljs-title function_">enable</span>(); 16071cb0ef41Sopenharmony_ci<span class="hljs-comment">// Do something.</span> 16081cb0ef41Sopenharmony_cih.<span class="hljs-title function_">disable</span>(); 16091cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-property">min</span>); 16101cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-property">max</span>); 16111cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-property">mean</span>); 16121cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-property">stddev</span>); 16131cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-property">percentiles</span>); 16141cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-title function_">percentile</span>(<span class="hljs-number">50</span>)); 16151cb0ef41Sopenharmony_ci<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(h.<span class="hljs-title function_">percentile</span>(<span class="hljs-number">99</span>));</code> <button class="copy-button">copy</button></pre> 16161cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>Histogram</code><span><a class="mark" href="#class-histogram" id="class-histogram">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_histogram"></a></h3> 16171cb0ef41Sopenharmony_ci<div class="api_metadata"> 16181cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 16191cb0ef41Sopenharmony_ci</div> 16201cb0ef41Sopenharmony_ci<h4><code>histogram.count</code><span><a class="mark" href="#histogramcount" id="histogramcount">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_count"></a></h4> 16211cb0ef41Sopenharmony_ci<div class="api_metadata"> 16221cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 16231cb0ef41Sopenharmony_ci</div> 16241cb0ef41Sopenharmony_ci<ul> 16251cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 16261cb0ef41Sopenharmony_ci</ul> 16271cb0ef41Sopenharmony_ci<p>The number of samples recorded by the histogram.</p> 16281cb0ef41Sopenharmony_ci<h4><code>histogram.countBigInt</code><span><a class="mark" href="#histogramcountbigint" id="histogramcountbigint">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_countbigint"></a></h4> 16291cb0ef41Sopenharmony_ci<div class="api_metadata"> 16301cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 16311cb0ef41Sopenharmony_ci</div> 16321cb0ef41Sopenharmony_ci<ul> 16331cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a></li> 16341cb0ef41Sopenharmony_ci</ul> 16351cb0ef41Sopenharmony_ci<p>The number of samples recorded by the histogram.</p> 16361cb0ef41Sopenharmony_ci<h4><code>histogram.exceeds</code><span><a class="mark" href="#histogramexceeds" id="histogramexceeds">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_exceeds"></a></h4> 16371cb0ef41Sopenharmony_ci<div class="api_metadata"> 16381cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 16391cb0ef41Sopenharmony_ci</div> 16401cb0ef41Sopenharmony_ci<ul> 16411cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 16421cb0ef41Sopenharmony_ci</ul> 16431cb0ef41Sopenharmony_ci<p>The number of times the event loop delay exceeded the maximum 1 hour event 16441cb0ef41Sopenharmony_ciloop delay threshold.</p> 16451cb0ef41Sopenharmony_ci<h4><code>histogram.exceedsBigInt</code><span><a class="mark" href="#histogramexceedsbigint" id="histogramexceedsbigint">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_exceedsbigint"></a></h4> 16461cb0ef41Sopenharmony_ci<div class="api_metadata"> 16471cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 16481cb0ef41Sopenharmony_ci</div> 16491cb0ef41Sopenharmony_ci<ul> 16501cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a></li> 16511cb0ef41Sopenharmony_ci</ul> 16521cb0ef41Sopenharmony_ci<p>The number of times the event loop delay exceeded the maximum 1 hour event 16531cb0ef41Sopenharmony_ciloop delay threshold.</p> 16541cb0ef41Sopenharmony_ci<h4><code>histogram.max</code><span><a class="mark" href="#histogrammax" id="histogrammax">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_max"></a></h4> 16551cb0ef41Sopenharmony_ci<div class="api_metadata"> 16561cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 16571cb0ef41Sopenharmony_ci</div> 16581cb0ef41Sopenharmony_ci<ul> 16591cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 16601cb0ef41Sopenharmony_ci</ul> 16611cb0ef41Sopenharmony_ci<p>The maximum recorded event loop delay.</p> 16621cb0ef41Sopenharmony_ci<h4><code>histogram.maxBigInt</code><span><a class="mark" href="#histogrammaxbigint" id="histogrammaxbigint">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_maxbigint"></a></h4> 16631cb0ef41Sopenharmony_ci<div class="api_metadata"> 16641cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 16651cb0ef41Sopenharmony_ci</div> 16661cb0ef41Sopenharmony_ci<ul> 16671cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a></li> 16681cb0ef41Sopenharmony_ci</ul> 16691cb0ef41Sopenharmony_ci<p>The maximum recorded event loop delay.</p> 16701cb0ef41Sopenharmony_ci<h4><code>histogram.mean</code><span><a class="mark" href="#histogrammean" id="histogrammean">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_mean"></a></h4> 16711cb0ef41Sopenharmony_ci<div class="api_metadata"> 16721cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 16731cb0ef41Sopenharmony_ci</div> 16741cb0ef41Sopenharmony_ci<ul> 16751cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 16761cb0ef41Sopenharmony_ci</ul> 16771cb0ef41Sopenharmony_ci<p>The mean of the recorded event loop delays.</p> 16781cb0ef41Sopenharmony_ci<h4><code>histogram.min</code><span><a class="mark" href="#histogrammin" id="histogrammin">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_min"></a></h4> 16791cb0ef41Sopenharmony_ci<div class="api_metadata"> 16801cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 16811cb0ef41Sopenharmony_ci</div> 16821cb0ef41Sopenharmony_ci<ul> 16831cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 16841cb0ef41Sopenharmony_ci</ul> 16851cb0ef41Sopenharmony_ci<p>The minimum recorded event loop delay.</p> 16861cb0ef41Sopenharmony_ci<h4><code>histogram.minBigInt</code><span><a class="mark" href="#histogramminbigint" id="histogramminbigint">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_minbigint"></a></h4> 16871cb0ef41Sopenharmony_ci<div class="api_metadata"> 16881cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 16891cb0ef41Sopenharmony_ci</div> 16901cb0ef41Sopenharmony_ci<ul> 16911cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a></li> 16921cb0ef41Sopenharmony_ci</ul> 16931cb0ef41Sopenharmony_ci<p>The minimum recorded event loop delay.</p> 16941cb0ef41Sopenharmony_ci<h4><code>histogram.percentile(percentile)</code><span><a class="mark" href="#histogrampercentilepercentile" id="histogrampercentilepercentile">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_percentile_percentile"></a></h4> 16951cb0ef41Sopenharmony_ci<div class="api_metadata"> 16961cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 16971cb0ef41Sopenharmony_ci</div> 16981cb0ef41Sopenharmony_ci<ul> 16991cb0ef41Sopenharmony_ci<li><code>percentile</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> A percentile value in the range (0, 100].</li> 17001cb0ef41Sopenharmony_ci<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 17011cb0ef41Sopenharmony_ci</ul> 17021cb0ef41Sopenharmony_ci<p>Returns the value at the given percentile.</p> 17031cb0ef41Sopenharmony_ci<h4><code>histogram.percentileBigInt(percentile)</code><span><a class="mark" href="#histogrampercentilebigintpercentile" id="histogrampercentilebigintpercentile">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_percentilebigint_percentile"></a></h4> 17041cb0ef41Sopenharmony_ci<div class="api_metadata"> 17051cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 17061cb0ef41Sopenharmony_ci</div> 17071cb0ef41Sopenharmony_ci<ul> 17081cb0ef41Sopenharmony_ci<li><code>percentile</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> A percentile value in the range (0, 100].</li> 17091cb0ef41Sopenharmony_ci<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a></li> 17101cb0ef41Sopenharmony_ci</ul> 17111cb0ef41Sopenharmony_ci<p>Returns the value at the given percentile.</p> 17121cb0ef41Sopenharmony_ci<h4><code>histogram.percentiles</code><span><a class="mark" href="#histogrampercentiles" id="histogrampercentiles">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_percentiles"></a></h4> 17131cb0ef41Sopenharmony_ci<div class="api_metadata"> 17141cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 17151cb0ef41Sopenharmony_ci</div> 17161cb0ef41Sopenharmony_ci<ul> 17171cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" class="type"><Map></a></li> 17181cb0ef41Sopenharmony_ci</ul> 17191cb0ef41Sopenharmony_ci<p>Returns a <code>Map</code> object detailing the accumulated percentile distribution.</p> 17201cb0ef41Sopenharmony_ci<h4><code>histogram.percentilesBigInt</code><span><a class="mark" href="#histogrampercentilesbigint" id="histogrampercentilesbigint">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_percentilesbigint"></a></h4> 17211cb0ef41Sopenharmony_ci<div class="api_metadata"> 17221cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 17231cb0ef41Sopenharmony_ci</div> 17241cb0ef41Sopenharmony_ci<ul> 17251cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map" class="type"><Map></a></li> 17261cb0ef41Sopenharmony_ci</ul> 17271cb0ef41Sopenharmony_ci<p>Returns a <code>Map</code> object detailing the accumulated percentile distribution.</p> 17281cb0ef41Sopenharmony_ci<h4><code>histogram.reset()</code><span><a class="mark" href="#histogramreset" id="histogramreset">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_reset"></a></h4> 17291cb0ef41Sopenharmony_ci<div class="api_metadata"> 17301cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 17311cb0ef41Sopenharmony_ci</div> 17321cb0ef41Sopenharmony_ci<p>Resets the collected histogram data.</p> 17331cb0ef41Sopenharmony_ci<h4><code>histogram.stddev</code><span><a class="mark" href="#histogramstddev" id="histogramstddev">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_stddev"></a></h4> 17341cb0ef41Sopenharmony_ci<div class="api_metadata"> 17351cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 17361cb0ef41Sopenharmony_ci</div> 17371cb0ef41Sopenharmony_ci<ul> 17381cb0ef41Sopenharmony_ci<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a></li> 17391cb0ef41Sopenharmony_ci</ul> 17401cb0ef41Sopenharmony_ci<p>The standard deviation of the recorded event loop delays.</p> 17411cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>IntervalHistogram extends Histogram</code><span><a class="mark" href="#class-intervalhistogram-extends-histogram" id="class-intervalhistogram-extends-histogram">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_intervalhistogram_extends_histogram"></a></h3> 17421cb0ef41Sopenharmony_ci<p>A <code>Histogram</code> that is periodically updated on a given interval.</p> 17431cb0ef41Sopenharmony_ci<h4><code>histogram.disable()</code><span><a class="mark" href="#histogramdisable" id="histogramdisable">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_disable"></a></h4> 17441cb0ef41Sopenharmony_ci<div class="api_metadata"> 17451cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 17461cb0ef41Sopenharmony_ci</div> 17471cb0ef41Sopenharmony_ci<ul> 17481cb0ef41Sopenharmony_ci<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> 17491cb0ef41Sopenharmony_ci</ul> 17501cb0ef41Sopenharmony_ci<p>Disables the update interval timer. Returns <code>true</code> if the timer was 17511cb0ef41Sopenharmony_cistopped, <code>false</code> if it was already stopped.</p> 17521cb0ef41Sopenharmony_ci<h4><code>histogram.enable()</code><span><a class="mark" href="#histogramenable" id="histogramenable">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_enable"></a></h4> 17531cb0ef41Sopenharmony_ci<div class="api_metadata"> 17541cb0ef41Sopenharmony_ci<span>Added in: v11.10.0</span> 17551cb0ef41Sopenharmony_ci</div> 17561cb0ef41Sopenharmony_ci<ul> 17571cb0ef41Sopenharmony_ci<li>Returns: <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type" class="type"><boolean></a></li> 17581cb0ef41Sopenharmony_ci</ul> 17591cb0ef41Sopenharmony_ci<p>Enables the update interval timer. Returns <code>true</code> if the timer was 17601cb0ef41Sopenharmony_cistarted, <code>false</code> if it was already started.</p> 17611cb0ef41Sopenharmony_ci<h4>Cloning an <code>IntervalHistogram</code><span><a class="mark" href="#cloning-an-intervalhistogram" id="cloning-an-intervalhistogram">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_cloning_an_intervalhistogram"></a></h4> 17621cb0ef41Sopenharmony_ci<p><a href="perf_hooks.html#class-intervalhistogram-extends-histogram" class="type"><IntervalHistogram></a> instances can be cloned via <a href="worker_threads.html#class-messageport" class="type"><MessagePort></a>. On the receiving 17631cb0ef41Sopenharmony_ciend, the histogram is cloned as a plain <a href="perf_hooks.html#class-histogram" class="type"><Histogram></a> object that does not 17641cb0ef41Sopenharmony_ciimplement the <code>enable()</code> and <code>disable()</code> methods.</p> 17651cb0ef41Sopenharmony_ci</section><section><h3>Class: <code>RecordableHistogram extends Histogram</code><span><a class="mark" href="#class-recordablehistogram-extends-histogram" id="class-recordablehistogram-extends-histogram">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_class_recordablehistogram_extends_histogram"></a></h3> 17661cb0ef41Sopenharmony_ci<div class="api_metadata"> 17671cb0ef41Sopenharmony_ci<span>Added in: v15.9.0, v14.18.0</span> 17681cb0ef41Sopenharmony_ci</div> 17691cb0ef41Sopenharmony_ci<h4><code>histogram.add(other)</code><span><a class="mark" href="#histogramaddother" id="histogramaddother">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_add_other"></a></h4> 17701cb0ef41Sopenharmony_ci<div class="api_metadata"> 17711cb0ef41Sopenharmony_ci<span>Added in: v17.4.0, v16.14.0</span> 17721cb0ef41Sopenharmony_ci</div> 17731cb0ef41Sopenharmony_ci<ul> 17741cb0ef41Sopenharmony_ci<li><code>other</code> <a href="perf_hooks.html#class-recordablehistogram-extends-histogram" class="type"><RecordableHistogram></a></li> 17751cb0ef41Sopenharmony_ci</ul> 17761cb0ef41Sopenharmony_ci<p>Adds the values from <code>other</code> to this histogram.</p> 17771cb0ef41Sopenharmony_ci<h4><code>histogram.record(val)</code><span><a class="mark" href="#histogramrecordval" id="histogramrecordval">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_record_val"></a></h4> 17781cb0ef41Sopenharmony_ci<div class="api_metadata"> 17791cb0ef41Sopenharmony_ci<span>Added in: v15.9.0, v14.18.0</span> 17801cb0ef41Sopenharmony_ci</div> 17811cb0ef41Sopenharmony_ci<ul> 17821cb0ef41Sopenharmony_ci<li><code>val</code> <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type" class="type"><number></a> | <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt" class="type"><bigint></a> The amount to record in the histogram.</li> 17831cb0ef41Sopenharmony_ci</ul> 17841cb0ef41Sopenharmony_ci<h4><code>histogram.recordDelta()</code><span><a class="mark" href="#histogramrecorddelta" id="histogramrecorddelta">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_histogram_recorddelta"></a></h4> 17851cb0ef41Sopenharmony_ci<div class="api_metadata"> 17861cb0ef41Sopenharmony_ci<span>Added in: v15.9.0, v14.18.0</span> 17871cb0ef41Sopenharmony_ci</div> 17881cb0ef41Sopenharmony_ci<p>Calculates the amount of time (in nanoseconds) that has passed since the 17891cb0ef41Sopenharmony_ciprevious call to <code>recordDelta()</code> and records that amount in the histogram.</p> 17901cb0ef41Sopenharmony_ci</section><section><h3>Examples<span><a class="mark" href="#examples" id="examples">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_examples"></a></h3> 17911cb0ef41Sopenharmony_ci<h4>Measuring the duration of async operations<span><a class="mark" href="#measuring-the-duration-of-async-operations" id="measuring-the-duration-of-async-operations">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_measuring_the_duration_of_async_operations"></a></h4> 17921cb0ef41Sopenharmony_ci<p>The following example uses the <a href="async_hooks.html">Async Hooks</a> and Performance APIs to measure 17931cb0ef41Sopenharmony_cithe actual duration of a Timeout operation (including the amount of time it took 17941cb0ef41Sopenharmony_cito execute the callback).</p> 17951cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-meta">'use strict'</span>; 17961cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> async_hooks = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:async_hooks'</span>); 17971cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { 17981cb0ef41Sopenharmony_ci performance, 17991cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 18001cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 18011cb0ef41Sopenharmony_ci 18021cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> set = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Set</span>(); 18031cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> hook = async_hooks.<span class="hljs-title function_">createHook</span>({ 18041cb0ef41Sopenharmony_ci <span class="hljs-title function_">init</span>(<span class="hljs-params">id, type</span>) { 18051cb0ef41Sopenharmony_ci <span class="hljs-keyword">if</span> (type === <span class="hljs-string">'Timeout'</span>) { 18061cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">`Timeout-<span class="hljs-subst">${id}</span>-Init`</span>); 18071cb0ef41Sopenharmony_ci set.<span class="hljs-title function_">add</span>(id); 18081cb0ef41Sopenharmony_ci } 18091cb0ef41Sopenharmony_ci }, 18101cb0ef41Sopenharmony_ci <span class="hljs-title function_">destroy</span>(<span class="hljs-params">id</span>) { 18111cb0ef41Sopenharmony_ci <span class="hljs-keyword">if</span> (set.<span class="hljs-title function_">has</span>(id)) { 18121cb0ef41Sopenharmony_ci set.<span class="hljs-title function_">delete</span>(id); 18131cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">mark</span>(<span class="hljs-string">`Timeout-<span class="hljs-subst">${id}</span>-Destroy`</span>); 18141cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">measure</span>(<span class="hljs-string">`Timeout-<span class="hljs-subst">${id}</span>`</span>, 18151cb0ef41Sopenharmony_ci <span class="hljs-string">`Timeout-<span class="hljs-subst">${id}</span>-Init`</span>, 18161cb0ef41Sopenharmony_ci <span class="hljs-string">`Timeout-<span class="hljs-subst">${id}</span>-Destroy`</span>); 18171cb0ef41Sopenharmony_ci } 18181cb0ef41Sopenharmony_ci }, 18191cb0ef41Sopenharmony_ci}); 18201cb0ef41Sopenharmony_cihook.<span class="hljs-title function_">enable</span>(); 18211cb0ef41Sopenharmony_ci 18221cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">list, observer</span>) =></span> { 18231cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(list.<span class="hljs-title function_">getEntries</span>()[<span class="hljs-number">0</span>]); 18241cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 18251cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 18261cb0ef41Sopenharmony_ci observer.<span class="hljs-title function_">disconnect</span>(); 18271cb0ef41Sopenharmony_ci}); 18281cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'measure'</span>], <span class="hljs-attr">buffered</span>: <span class="hljs-literal">true</span> }); 18291cb0ef41Sopenharmony_ci 18301cb0ef41Sopenharmony_ci<span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =></span> {}, <span class="hljs-number">1000</span>);</code> <button class="copy-button">copy</button></pre> 18311cb0ef41Sopenharmony_ci<h4>Measuring how long it takes to load dependencies<span><a class="mark" href="#measuring-how-long-it-takes-to-load-dependencies" id="measuring-how-long-it-takes-to-load-dependencies">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_measuring_how_long_it_takes_to_load_dependencies"></a></h4> 18321cb0ef41Sopenharmony_ci<p>The following example measures the duration of <code>require()</code> operations to load 18331cb0ef41Sopenharmony_cidependencies:</p> 18341cb0ef41Sopenharmony_ci<!-- eslint-disable no-global-assign --> 18351cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-meta">'use strict'</span>; 18361cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { 18371cb0ef41Sopenharmony_ci performance, 18381cb0ef41Sopenharmony_ci <span class="hljs-title class_">PerformanceObserver</span>, 18391cb0ef41Sopenharmony_ci} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 18401cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> mod = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:module'</span>); 18411cb0ef41Sopenharmony_ci 18421cb0ef41Sopenharmony_ci<span class="hljs-comment">// Monkey patch the require function</span> 18431cb0ef41Sopenharmony_cimod.<span class="hljs-property">Module</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">require</span> = 18441cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">timerify</span>(mod.<span class="hljs-property">Module</span>.<span class="hljs-property"><span class="hljs-keyword">prototype</span></span>.<span class="hljs-property">require</span>); 18451cb0ef41Sopenharmony_ci<span class="hljs-built_in">require</span> = performance.<span class="hljs-title function_">timerify</span>(<span class="hljs-built_in">require</span>); 18461cb0ef41Sopenharmony_ci 18471cb0ef41Sopenharmony_ci<span class="hljs-comment">// Activate the observer</span> 18481cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">list</span>) =></span> { 18491cb0ef41Sopenharmony_ci <span class="hljs-keyword">const</span> entries = list.<span class="hljs-title function_">getEntries</span>(); 18501cb0ef41Sopenharmony_ci entries.<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">entry</span>) =></span> { 18511cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(<span class="hljs-string">`require('<span class="hljs-subst">${entry[<span class="hljs-number">0</span>]}</span>')`</span>, entry.<span class="hljs-property">duration</span>); 18521cb0ef41Sopenharmony_ci }); 18531cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMarks</span>(); 18541cb0ef41Sopenharmony_ci performance.<span class="hljs-title function_">clearMeasures</span>(); 18551cb0ef41Sopenharmony_ci obs.<span class="hljs-title function_">disconnect</span>(); 18561cb0ef41Sopenharmony_ci}); 18571cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'function'</span>], <span class="hljs-attr">buffered</span>: <span class="hljs-literal">true</span> }); 18581cb0ef41Sopenharmony_ci 18591cb0ef41Sopenharmony_ci<span class="hljs-built_in">require</span>(<span class="hljs-string">'some-module'</span>);</code> <button class="copy-button">copy</button></pre> 18601cb0ef41Sopenharmony_ci<h4>Measuring how long one HTTP round-trip takes<span><a class="mark" href="#measuring-how-long-one-http-round-trip-takes" id="measuring-how-long-one-http-round-trip-takes">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_measuring_how_long_one_http_round_trip_takes"></a></h4> 18611cb0ef41Sopenharmony_ci<p>The following example is used to trace the time spent by HTTP client 18621cb0ef41Sopenharmony_ci(<code>OutgoingMessage</code>) and HTTP request (<code>IncomingMessage</code>). For HTTP client, 18631cb0ef41Sopenharmony_ciit means the time interval between starting the request and receiving the 18641cb0ef41Sopenharmony_ciresponse, and for HTTP request, it means the time interval between receiving 18651cb0ef41Sopenharmony_cithe request and sending the response:</p> 18661cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-meta">'use strict'</span>; 18671cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { <span class="hljs-title class_">PerformanceObserver</span> } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 18681cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> http = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:http'</span>); 18691cb0ef41Sopenharmony_ci 18701cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">items</span>) =></span> { 18711cb0ef41Sopenharmony_ci items.<span class="hljs-title function_">getEntries</span>().<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">item</span>) =></span> { 18721cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(item); 18731cb0ef41Sopenharmony_ci }); 18741cb0ef41Sopenharmony_ci}); 18751cb0ef41Sopenharmony_ci 18761cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'http'</span>] }); 18771cb0ef41Sopenharmony_ci 18781cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> <span class="hljs-variable constant_">PORT</span> = <span class="hljs-number">8080</span>; 18791cb0ef41Sopenharmony_ci 18801cb0ef41Sopenharmony_cihttp.<span class="hljs-title function_">createServer</span>(<span class="hljs-function">(<span class="hljs-params">req, res</span>) =></span> { 18811cb0ef41Sopenharmony_ci res.<span class="hljs-title function_">end</span>(<span class="hljs-string">'ok'</span>); 18821cb0ef41Sopenharmony_ci}).<span class="hljs-title function_">listen</span>(<span class="hljs-variable constant_">PORT</span>, <span class="hljs-function">() =></span> { 18831cb0ef41Sopenharmony_ci http.<span class="hljs-title function_">get</span>(<span class="hljs-string">`http://127.0.0.1:<span class="hljs-subst">${PORT}</span>`</span>); 18841cb0ef41Sopenharmony_ci});</code> <button class="copy-button">copy</button></pre> 18851cb0ef41Sopenharmony_ci<h4>Measuring how long the <code>net.connect</code> (only for TCP) takes when the connection is successful<span><a class="mark" href="#measuring-how-long-the-netconnect-only-for-tcp-takes-when-the-connection-is-successful" id="measuring-how-long-the-netconnect-only-for-tcp-takes-when-the-connection-is-successful">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_measuring_how_long_the_net_connect_only_for_tcp_takes_when_the_connection_is_successful"></a></h4> 18861cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-meta">'use strict'</span>; 18871cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { <span class="hljs-title class_">PerformanceObserver</span> } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 18881cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> net = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:net'</span>); 18891cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">items</span>) =></span> { 18901cb0ef41Sopenharmony_ci items.<span class="hljs-title function_">getEntries</span>().<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">item</span>) =></span> { 18911cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(item); 18921cb0ef41Sopenharmony_ci }); 18931cb0ef41Sopenharmony_ci}); 18941cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'net'</span>] }); 18951cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> <span class="hljs-variable constant_">PORT</span> = <span class="hljs-number">8080</span>; 18961cb0ef41Sopenharmony_cinet.<span class="hljs-title function_">createServer</span>(<span class="hljs-function">(<span class="hljs-params">socket</span>) =></span> { 18971cb0ef41Sopenharmony_ci socket.<span class="hljs-title function_">destroy</span>(); 18981cb0ef41Sopenharmony_ci}).<span class="hljs-title function_">listen</span>(<span class="hljs-variable constant_">PORT</span>, <span class="hljs-function">() =></span> { 18991cb0ef41Sopenharmony_ci net.<span class="hljs-title function_">connect</span>(<span class="hljs-variable constant_">PORT</span>); 19001cb0ef41Sopenharmony_ci});</code> <button class="copy-button">copy</button></pre> 19011cb0ef41Sopenharmony_ci<h4>Measuring how long the DNS takes when the request is successful<span><a class="mark" href="#measuring-how-long-the-dns-takes-when-the-request-is-successful" id="measuring-how-long-the-dns-takes-when-the-request-is-successful">#</a></span><a aria-hidden="true" class="legacy" id="perf_hooks_measuring_how_long_the_dns_takes_when_the_request_is_successful"></a></h4> 19021cb0ef41Sopenharmony_ci<pre><code class="language-js"><span class="hljs-meta">'use strict'</span>; 19031cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> { <span class="hljs-title class_">PerformanceObserver</span> } = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:perf_hooks'</span>); 19041cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> dns = <span class="hljs-built_in">require</span>(<span class="hljs-string">'node:dns'</span>); 19051cb0ef41Sopenharmony_ci<span class="hljs-keyword">const</span> obs = <span class="hljs-keyword">new</span> <span class="hljs-title class_">PerformanceObserver</span>(<span class="hljs-function">(<span class="hljs-params">items</span>) =></span> { 19061cb0ef41Sopenharmony_ci items.<span class="hljs-title function_">getEntries</span>().<span class="hljs-title function_">forEach</span>(<span class="hljs-function">(<span class="hljs-params">item</span>) =></span> { 19071cb0ef41Sopenharmony_ci <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(item); 19081cb0ef41Sopenharmony_ci }); 19091cb0ef41Sopenharmony_ci}); 19101cb0ef41Sopenharmony_ciobs.<span class="hljs-title function_">observe</span>({ <span class="hljs-attr">entryTypes</span>: [<span class="hljs-string">'dns'</span>] }); 19111cb0ef41Sopenharmony_cidns.<span class="hljs-title function_">lookup</span>(<span class="hljs-string">'localhost'</span>, <span class="hljs-function">() =></span> {}); 19121cb0ef41Sopenharmony_cidns.<span class="hljs-property">promises</span>.<span class="hljs-title function_">resolve</span>(<span class="hljs-string">'localhost'</span>);</code> <button class="copy-button">copy</button></pre></section> 19131cb0ef41Sopenharmony_ci <!-- API END --> 19141cb0ef41Sopenharmony_ci </div> 19151cb0ef41Sopenharmony_ci </div> 19161cb0ef41Sopenharmony_ci </div> 19171cb0ef41Sopenharmony_ci</body> 19181cb0ef41Sopenharmony_ci</html> 1919