mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
[ReactNative] Optimize console.profile and add markers on JS entry points
Summary:
@public
Right now the profiler shows how long the executor took on JS but doesn't show
how long each of the batched calls took, this adds a *very* high level view of JS
execution (still doesn't show properly calls dispatched with setImmediate)
Also added a global property on JS to avoid trips to Native when profiling is
disabled.
Test Plan:
Run the Profiler on any app
{F22491690}
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
* before before using it.
|
||||
*/
|
||||
|
||||
NSString *const RCTProfileDidStartProfiling;
|
||||
NSString *const RCTProfileDidEndProfiling;
|
||||
|
||||
#if RCT_DEV
|
||||
|
||||
#define RCTProfileBeginFlowEvent() \
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
NSString *const RCTProfileDidStartProfiling = @"RCTProfileDidStartProfiling";
|
||||
NSString *const RCTProfileDidEndProfiling = @"RCTProfileDidEndProfiling";
|
||||
|
||||
#if RCT_DEV
|
||||
|
||||
#pragma mark - Prototypes
|
||||
@@ -113,10 +116,16 @@ void RCTProfileInit(void)
|
||||
RCTProfileSamples: [[NSMutableArray alloc] init],
|
||||
};
|
||||
);
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidStartProfiling
|
||||
object:nil];
|
||||
}
|
||||
|
||||
NSString *RCTProfileEnd(void)
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTProfileDidEndProfiling
|
||||
object:nil];
|
||||
|
||||
RCTProfileLock(
|
||||
NSString *log = RCTJSONStringify(RCTProfileInfo, NULL);
|
||||
RCTProfileEventID = 0;
|
||||
|
||||
Reference in New Issue
Block a user