react-native/docs/systrace.md

3.1 KiB

id title layout category permalink next previous
systrace Systrace docs APIs docs/systrace.html timepickerandroid stylesheet

Methods


Reference

Methods

installReactHook()

static installReactHook(useFiber)

setEnabled()

static setEnabled(enabled)

isEnabled()

static isEnabled()

beginEvent()

static beginEvent(profileName?, args?)

beginEvent/endEvent for starting and then ending a profile within the same call stack frame


endEvent()

static endEvent()

beginAsyncEvent()

static beginAsyncEvent(profileName?)

beginAsyncEvent/endAsyncEvent for starting and then ending a profile where the end can either occur on another thread or out of the current stack frame, eg await the returned cookie variable should be used as input into the endAsyncEvent call to end the profile


endAsyncEvent()

static endAsyncEvent(profileName?, cookie?)

counterEvent()

static counterEvent(profileName?, value?)

counterEvent registers the value to the profileName on the systrace timeline


attachToRelayProfiler()

static attachToRelayProfiler(relayProfiler)

Relay profiles use await calls, so likely occur out of current stack frame therefore async variant of profiling is used


swizzleJSON()

static swizzleJSON()

This is not called by default due to perf overhead but it's useful if you want to find traces which spend too much time in JSON.


measureMethods()

static measureMethods(object, objectName, methodNames)

Measures multiple methods of a class. For example, you can do:

Systrace.measureMethods(JSON, 'JSON', ['parse', 'stringify']);

Parameters:

Name Type Required Description
object any Yes
objectName string Yes
methodNames array Yes Map from method names to method display names.

measure()

static measure(objName, fnName, func)

Returns an profiled version of the input function. For example, you can:

JSON.parse = Systrace.measure('JSON', 'parse', JSON.parse);

Parameters:

Name Type Required Description
objName string Yes
fnName string Yes
func function Yes