Skip to main content

Perf monitor

The perf monitor is an overlay with frame rates and memory use. It is painted by the renderer above every window, so it does not compete with the app it measures. It is also available from the dev menu.

The Perf Monitor overlay in the corner of an app window

React TSX
import { PerfMonitor } from '@react-native-gpui/core/desktop';

await PerfMonitor.setEnabled(true);

Methods​

MethodDescription
PerfMonitor.setEnabled(on)Shows or hides the overlay. Resolves with the new state.
PerfMonitor.isEnabled()Whether the overlay is showing.
PerfMonitor.toggle()Switches it, and resolves with the new state.
PerfMonitor.getMetrics()Resolves with the current PerfMetrics.

Metrics​

FieldDescription
enabledWhether the monitor is on.
uiFpsFrames the renderer drew in the last second.
jsFpsTasks the JavaScript thread ran in the last second, one posted per frame.
memoryBytesMemory used by the app.
jsHeapBytesBytes the JavaScript engine reports as allocated. 0 when the engine does not say.
droppedFramesDisplay refreshes without a new frame since the monitor was enabled.
stuttersThe number of times four or more frames were dropped in a row.
mountedViewsThe number of views currently mounted.
lastMountMsHow long the last mount took, in milliseconds.

The JavaScript frame rate is measured natively: the host posts a task to the JavaScript thread each frame and counts the ones that ran, so the measurement does not add work to the thread it measures.