Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Profiler

Profiler

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheProfiler interface of theJS Self-Profiling API enables you to create aprofile of some part of your web application's execution.

Constructor

Profiler()Experimental

Creates a newProfiler object, and starts collecting samples.

Instance methods

Profiler.stop()Experimental

Stops the profiler, returning aPromise that resolves to theprofile.

Events

samplebufferfull

Fired when the profile has recorded enough samples to fill its internal buffer.

Examples

Recording a profile

The following code profiles thedoWork() operation, and logs the result.

js
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 10000 });doWork();const profile = await profiler.stop();console.log(JSON.stringify(profile));

Profiling page load

The following code profiles the time between the script first running and the window'sload event firing.

js
const profiler = new Profiler({ sampleInterval: 10, maxBufferSize: 10000 });window.addEventListener("load", async () => {  const profile = await profiler.stop();  console.log(JSON.stringify(profile));});

Specifications

Specification
JS Self-Profiling API
# the-profiler-interface

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp