diff --git a/Libraries/BatchedBridge/BatchedBridge.js b/Libraries/BatchedBridge/BatchedBridge.js index e4269735a..6d25db30e 100644 --- a/Libraries/BatchedBridge/BatchedBridge.js +++ b/Libraries/BatchedBridge/BatchedBridge.js @@ -19,10 +19,10 @@ const BatchedBridge = new MessageQueue( // TODO: Move these around to solve the cycle in a cleaner way. -const BridgeProfiling = require('BridgeProfiling'); +const Systrace = require('Systrace'); const JSTimersExecution = require('JSTimersExecution'); -BatchedBridge.registerCallableModule('BridgeProfiling', BridgeProfiling); +BatchedBridge.registerCallableModule('Systrace', Systrace); BatchedBridge.registerCallableModule('JSTimersExecution', JSTimersExecution); // Wire up the batched bridge on the global object so that we can call into it. diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index 141ea7045..cb6ba3275 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -165,8 +165,8 @@ function setUpWebSockets() { function setUpProfile() { if (__DEV__) { - var BridgeProfiling = require('BridgeProfiling'); - BridgeProfiling.swizzleReactPerf(); + var Systrace = require('Systrace'); + Systrace.swizzleReactPerf(); } } diff --git a/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js b/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js index 07a324d41..c85c155a7 100644 --- a/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js +++ b/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js @@ -14,7 +14,7 @@ var invariant = require('invariant'); var keyMirror = require('keyMirror'); var performanceNow = require('performanceNow'); var warning = require('warning'); -var BridgeProfiling = require('BridgeProfiling'); +var Systrace = require('Systrace'); /** * JS implementation of timer functions. Must be completely driven by an @@ -113,7 +113,7 @@ var JSTimersExecution = { * more immediates are queued up (can be used as a condition a while loop). */ callImmediatesPass: function() { - BridgeProfiling.profile('JSTimersExecution.callImmediatesPass()'); + Systrace.beginEvent('JSTimersExecution.callImmediatesPass()'); // The main reason to extract a single pass is so that we can track // in the system trace @@ -128,7 +128,7 @@ var JSTimersExecution = { } } - BridgeProfiling.profileEnd(); + Systrace.endEvent(); return JSTimersExecution.immediates.length > 0; }, diff --git a/Libraries/Utilities/MessageQueue.js b/Libraries/Utilities/MessageQueue.js index 888afea2a..10a41919a 100644 --- a/Libraries/Utilities/MessageQueue.js +++ b/Libraries/Utilities/MessageQueue.js @@ -13,7 +13,7 @@ 'use strict'; -let BridgeProfiling = require('BridgeProfiling'); +let Systrace = require('Systrace'); let ErrorUtils = require('ErrorUtils'); let JSTimersExecution = require('JSTimersExecution'); @@ -114,9 +114,9 @@ class MessageQueue { */ __callImmediates() { - BridgeProfiling.profile('JSTimersExecution.callImmediates()'); + Systrace.beginEvent('JSTimersExecution.callImmediates()'); guard(() => JSTimersExecution.callImmediates()); - BridgeProfiling.profileEnd(); + Systrace.endEvent(); } __nativeCall(module, method, params, onFail, onSucc) { @@ -154,7 +154,7 @@ class MessageQueue { method = this._methodTable[module][method]; module = this._moduleTable[module]; } - BridgeProfiling.profile(() => `${module}.${method}(${stringifySafe(args)})`); + Systrace.beginEvent(() => `${module}.${method}(${stringifySafe(args)})`); if (__DEV__ && SPY_MODE) { console.log('N->JS : ' + module + '.' + method + '(' + JSON.stringify(args) + ')'); } @@ -165,11 +165,11 @@ class MessageQueue { module ); moduleMethods[method].apply(moduleMethods, args); - BridgeProfiling.profileEnd(); + Systrace.endEvent(); } __invokeCallback(cbID, args) { - BridgeProfiling.profile( + Systrace.beginEvent( () => `MessageQueue.invokeCallback(${cbID}, ${stringifySafe(args)})`); this._lastFlush = new Date().getTime(); let callback = this._callbacks[cbID]; @@ -188,7 +188,7 @@ class MessageQueue { this._callbacks[cbID & ~1] = null; this._callbacks[cbID | 1] = null; callback.apply(null, args); - BridgeProfiling.profileEnd(); + Systrace.endEvent(); } /** @@ -244,7 +244,7 @@ class MessageQueue { this._genLookup(config, moduleID, moduleTable, methodTable); }); } - + _genLookup(config, moduleID, moduleTable, methodTable) { if (!config) { return; @@ -287,15 +287,15 @@ class MessageQueue { module[methodName] = this._genMethod(moduleID, methodID, methodType); }); Object.assign(module, constants); - + if (!constants && !methods && !asyncMethods) { module.moduleID = moduleID; } - + this.RemoteModules[moduleName] = module; return module; } - + _genMethod(module, method, type) { let fn = null; let self = this; diff --git a/Libraries/Utilities/BridgeProfiling.js b/Libraries/Utilities/Systrace.js similarity index 77% rename from Libraries/Utilities/BridgeProfiling.js rename to Libraries/Utilities/Systrace.js index 36cb86252..826be67a1 100644 --- a/Libraries/Utilities/BridgeProfiling.js +++ b/Libraries/Utilities/Systrace.js @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule BridgeProfiling + * @providesModule Systrace * @flow */ 'use strict'; @@ -32,7 +32,7 @@ function ReactPerf() { return _ReactPerf; } -var BridgeProfiling = { +var Systrace = { setEnabled(enabled: boolean) { if (_enabled !== enabled) { if (enabled) { @@ -47,9 +47,9 @@ var BridgeProfiling = { }, /** - * profile/profileEnd for starting and then ending a profile within the same call stack frame + * beginEvent/endEvent for starting and then ending a profile within the same call stack frame **/ - profile(profileName?: any) { + beginEvent(profileName?: any) { if (_enabled) { profileName = typeof profileName === 'function' ? profileName() : profileName; @@ -57,18 +57,18 @@ var BridgeProfiling = { } }, - profileEnd() { + endEvent() { if (_enabled) { global.nativeTraceEndSection(TRACE_TAG_REACT_APPS); } }, /** - * profileAsync/profileAsyncEnd for starting and then ending a profile where the end can either + * 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 asyncEnd call to end the profile + * the returned cookie variable should be used as input into the endAsyncEvent call to end the profile **/ - profileAsync(profileName?: any): any { + beginAsyncEvent(profileName?: any): any { var cookie = _asyncCookie; if (_enabled) { _asyncCookie++; @@ -79,7 +79,7 @@ var BridgeProfiling = { return cookie; }, - profileAsyncEnd(profileName?: any, cookie?: any) { + endAsyncEvent(profileName?: any, cookie?: any) { if (_enabled) { profileName = typeof profileName === 'function' ? profileName() : profileName; @@ -94,15 +94,15 @@ var BridgeProfiling = { } var name = objName === 'ReactCompositeComponent' && this.getName() || ''; - BridgeProfiling.profile(`${objName}.${fnName}(${name})`); + Systrace.beginEvent(`${objName}.${fnName}(${name})`); var ret = func.apply(this, arguments); - BridgeProfiling.profileEnd(); + Systrace.endEvent(); return ret; }; }, swizzleReactPerf() { - ReactPerf().injection.injectMeasure(BridgeProfiling.reactPerfMeasure); + ReactPerf().injection.injectMeasure(Systrace.reactPerfMeasure); }, /** @@ -111,9 +111,9 @@ var BridgeProfiling = { **/ attachToRelayProfiler(relayProfiler: RelayProfiler) { relayProfiler.attachProfileHandler('*', (name) => { - var cookie = BridgeProfiling.profileAsync(name); + var cookie = Systrace.beginAsyncEvent(name); return () => { - BridgeProfiling.profileAsyncEnd(name, cookie); + Systrace.endAsyncEvent(name, cookie); }; }); }, @@ -121,7 +121,7 @@ var BridgeProfiling = { /* 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() { - BridgeProfiling.measureMethods(JSON, 'JSON', [ + Systrace.measureMethods(JSON, 'JSON', [ 'parse', 'stringify' ]); @@ -129,7 +129,7 @@ var BridgeProfiling = { /** * Measures multiple methods of a class. For example, you can do: - * BridgeProfiling.measureMethods(JSON, 'JSON', ['parse', 'stringify']); + * Systrace.measureMethods(JSON, 'JSON', ['parse', 'stringify']); * * @param object * @param objectName @@ -141,7 +141,7 @@ var BridgeProfiling = { } methodNames.forEach(methodName => { - object[methodName] = BridgeProfiling.measure( + object[methodName] = Systrace.measure( objectName, methodName, object[methodName] @@ -151,7 +151,7 @@ var BridgeProfiling = { /** * Returns an profiled version of the input function. For example, you can: - * JSON.parse = BridgeProfiling.measure('JSON', 'parse', JSON.parse); + * JSON.parse = Systrace.measure('JSON', 'parse', JSON.parse); * * @param objName * @param fnName @@ -169,14 +169,14 @@ var BridgeProfiling = { return func.apply(this, arguments); } - BridgeProfiling.profile(profileName); + Systrace.beginEvent(profileName); var ret = func.apply(this, arguments); - BridgeProfiling.profileEnd(); + Systrace.endEvent(); return ret; }; }, }; -BridgeProfiling.setEnabled(global.__RCTProfileIsProfiling || false); +Systrace.setEnabled(global.__RCTProfileIsProfiling || false); -module.exports = BridgeProfiling; +module.exports = Systrace; diff --git a/React/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m index d37f6c7b9..55b0d506c 100644 --- a/React/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -418,7 +418,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context) [self executeBlockOnJavaScriptQueue:^{ BOOL enabled = [notification.name isEqualToString:RCTProfileDidStartProfiling]; // TODO: Don't use require, go through the normal execution modes instead. #9317773 - NSString *script = [NSString stringWithFormat:@"var p = require('BridgeProfiling') || {}; p.setEnabled && p.setEnabled(%@)", enabled ? @"true" : @"false"]; + NSString *script = [NSString stringWithFormat:@"var p = require('Systrace') || {}; p.setEnabled && p.setEnabled(%@)", enabled ? @"true" : @"false"]; JSStringRef scriptJSRef = JSStringCreateWithUTF8CString(script.UTF8String); JSEvaluateScript(_context.ctx, scriptJSRef, NULL, NULL, 0, NULL); JSStringRelease(scriptJSRef); diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 28bc76f82..07b18b066 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -13,7 +13,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.facebook.react.bridge.BridgeProfiling; import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; @@ -95,7 +94,7 @@ import com.facebook.systrace.Systrace; RCTEventEmitter.class, RCTNativeAppEventEmitter.class, AppRegistry.class, - BridgeProfiling.class, + com.facebook.react.bridge.Systrace.class, DebugComponentOwnershipModule.RCTDebugComponentOwnership.class); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 06d53a85e..87ae11a2b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -469,12 +469,12 @@ public class CatalystInstanceImpl implements CatalystInstance { private class JSProfilerTraceListener implements TraceListener { @Override public void onTraceStarted() { - getJSModule(BridgeProfiling.class).setEnabled(true); + getJSModule(com.facebook.react.bridge.Systrace.class).setEnabled(true); } @Override public void onTraceStopped() { - getJSModule(BridgeProfiling.class).setEnabled(false); + getJSModule(com.facebook.react.bridge.Systrace.class).setEnabled(false); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeProfiling.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/Systrace.java similarity index 66% rename from ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeProfiling.java rename to ReactAndroid/src/main/java/com/facebook/react/bridge/Systrace.java index 50a3a72b9..9f571e865 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/BridgeProfiling.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/Systrace.java @@ -5,10 +5,10 @@ package com.facebook.react.bridge; import com.facebook.proguard.annotations.DoNotStrip; /** - * Interface to the JavaScript BridgeProfiling Module + * Interface to the JavaScript Systrace Module */ @DoNotStrip -public interface BridgeProfiling extends JavaScriptModule{ +public interface Systrace extends JavaScriptModule{ @DoNotStrip void setEnabled(boolean enabled); } diff --git a/packager/react-packager/src/Resolver/polyfills/require.js b/packager/react-packager/src/Resolver/polyfills/require.js index ebaa8c406..506d38e02 100644 --- a/packager/react-packager/src/Resolver/polyfills/require.js +++ b/packager/react-packager/src/Resolver/polyfills/require.js @@ -54,13 +54,13 @@ // require cycles inside the factory from causing an infinite require loop. mod.isInitialized = true; - __DEV__ && BridgeProfiling().profile('JS_require_' + id); + __DEV__ && Systrace().beginEvent('JS_require_' + id); // keep args in sync with with defineModuleCode in // packager/react-packager/src/Resolver/index.js mod.factory.call(global, global, require, mod.module, mod.module.exports); - __DEV__ && BridgeProfiling().profileEnd(); + __DEV__ && Systrace().endEvent(); } catch (e) { mod.hasError = true; mod.isInitialized = false; @@ -70,14 +70,14 @@ return mod.module.exports; } - const BridgeProfiling = __DEV__ && (() => { - var _BridgeProfiling; + const Systrace = __DEV__ && (() => { + var _Systrace; try { - _BridgeProfiling = require('BridgeProfiling'); + _Systrace = require('Systrace'); } catch(e) {} - return _BridgeProfiling && _BridgeProfiling.profile ? - _BridgeProfiling : { profile: () => {}, profileEnd: () => {} }; + return _Systrace && _Systrace.beginEvent ? + _Systrace : { beginEvent: () => {}, endEvent: () => {} }; }); global.__d = define;