mirror of
https://github.com/status-im/react-native.git
synced 2025-02-26 16:10:58 +00:00
RN: Delete Systrace.swizzleJSON
Reviewed By: TheSavior Differential Revision: D7207460 fbshipit-source-id: 14b1174d6a5c75e1acba7272376d1c462bc13cb6
This commit is contained in:
parent
a8c4b630fc
commit
3e141cb6c9
@ -182,65 +182,6 @@ const Systrace = {
|
||||
global.nativeTraceCounter(TRACE_TAG_REACT_APPS, profileName, value);
|
||||
}
|
||||
},
|
||||
|
||||
/* 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. */
|
||||
swizzleJSON() {
|
||||
Systrace.measureMethods(JSON, 'JSON', ['parse', 'stringify']);
|
||||
},
|
||||
|
||||
/**
|
||||
* Measures multiple methods of a class. For example, you can do:
|
||||
* Systrace.measureMethods(JSON, 'JSON', ['parse', 'stringify']);
|
||||
*
|
||||
* @param object
|
||||
* @param objectName
|
||||
* @param methodNames Map from method names to method display names.
|
||||
*/
|
||||
measureMethods(
|
||||
object: any,
|
||||
objectName: string,
|
||||
methodNames: Array<string>,
|
||||
): void {
|
||||
if (!__DEV__) {
|
||||
return;
|
||||
}
|
||||
|
||||
methodNames.forEach(methodName => {
|
||||
object[methodName] = Systrace.measure(
|
||||
objectName,
|
||||
methodName,
|
||||
object[methodName],
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an profiled version of the input function. For example, you can:
|
||||
* JSON.parse = Systrace.measure('JSON', 'parse', JSON.parse);
|
||||
*
|
||||
* @param objName
|
||||
* @param fnName
|
||||
* @param {function} func
|
||||
* @return {function} replacement function
|
||||
*/
|
||||
measure(objName: string, fnName: string, func: any): any {
|
||||
if (!__DEV__) {
|
||||
return func;
|
||||
}
|
||||
|
||||
const profileName = `${objName}.${fnName}`;
|
||||
return function() {
|
||||
if (!_enabled) {
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
|
||||
Systrace.beginEvent(profileName);
|
||||
const ret = func.apply(this, arguments);
|
||||
Systrace.endEvent();
|
||||
return ret;
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
if (__DEV__) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user