Skip to content

Add _startProfiling and _stopProfiling JSI bindings for Hermes sampling profiler#9102

Merged
tomekzaw merged 11 commits into
mainfrom
@tomekzaw/jsi-hermes-sampling-profiler
Mar 17, 2026
Merged

Add _startProfiling and _stopProfiling JSI bindings for Hermes sampling profiler#9102
tomekzaw merged 11 commits into
mainfrom
@tomekzaw/jsi-hermes-sampling-profiler

Conversation

@tomekzaw

@tomekzaw tomekzaw commented Mar 14, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds _startProfiling and _stopProfiling JSI bindings in worklet runtimes that enable and disable Hermes sampling profiler on the Reanimated UI runtime.

I took some inspiration from https://github.com/margelo/react-native-release-profiler/blob/main/ios/ReleaseProfiler.mm.

Usage:

scheduleOnUI(() => {
  globalThis._startProfiling();
});

scheduleOnUI(() => {
  const path = globalThis._stopProfiling();
  console.log(`Trace saved to ${path})`);
});

The trace is saved on device and the path is returned from _stopProfiling so it can be printed to the console:
Screenshot 2026-03-14 at 11 02 44

The trace file can be opened with https://www.speedscope.app/

Screenshot 2026-03-14 at 10 55 41

Test plan

@tomekzaw tomekzaw added this pull request to the merge queue Mar 17, 2026
Merged via the queue into main with commit 2f5ddf4 Mar 17, 2026
22 checks passed
@tomekzaw tomekzaw deleted the @tomekzaw/jsi-hermes-sampling-profiler branch March 17, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants