Back to Content

Profiler: stop() method

files/en-us/web/api/profiler/stop/index.md

latest899 B
Original Source

{{APIRef("JS Self-Profiling API")}}{{SeeCompatTable}}

The stop() method of the {{domxref("Profiler")}} interface stops the profiler and returns a {{jsxref("Promise")}} which resolves to the profile itself.

Syntax

js-nolint
stop()

Parameters

None.

Return value

A {{jsxref("Promise")}} that resolves to an object containing the profile data. The format and interpretation of this object is described in Profile anatomy and format.

Examples

Recording a profile

The following code profiles the doWork() 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));

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}