packages/react-native/ReactCommon/jsinspector-modern/__docs__/consoleTimeStamp.md
The console.timeStamp API provides a way to record markers on the timeline of the Performance instrumentation.
The idea is to have a highly performant API for instrumenting React Native applications and surfacing the recorded timing data to performance tooling: Performance panel or Perfetto. This API should be explicitly designed to have minimal runtime overhead and expected to be used for instrumenting hot paths and profiling (production) builds.
See also:
The console.timeStamp() method can be called with various parameters to record
markers on the performance timeline:
// Basic usage with just a label
console.timeStamp('Click');
// Advanced usage with start and end markers
console.timeStamp('Animation', performance.now(), performance.now() + 500);
// Full usage with all parameters
console.timeStamp(
'Animation', // label
performance.now(), // start time
performance.now() + 500, // end time
'UI Animations', // track name
'Main Thread', // track group
'primary', // color
);
More examples are available on Chrome DevTools website.
label (required): A string label for the timestamp markerstart (optional): A
DOMHighResTimeStamp
or string marker for the start timeend (optional): A
DOMHighResTimeStamp
or string marker for the end timetrackName (optional): A string specifying the track nametrackGroup (optional): A string specifying the track groupcolor (optional): A string specifying the color of the timestamp marker.
Supported values depend on Performance instrumentation, for React Native
DevTools, the supported values are listed in ConsoleTimeStamp.h.The console.timeStamp API is a JSI Host Function that is installed as part of the Console interface when JavaScript Runtime target is registered with the jsinspector-modern stack.
To achieve minimal runtime costs:
With Chrome DevTools Performance panel integration:
label specified) are not reported to custom tracks. They are
only reported as "TimeStamp: <label>" entries on the Timings track.