[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:
Tadeu Zagallo
2015-06-02 06:15:53 -07:00
parent 2dfa3b34a1
commit 0f16d15d64
6 changed files with 101 additions and 5 deletions

View File

@@ -20,6 +20,9 @@
* before before using it.
*/
NSString *const RCTProfileDidStartProfiling;
NSString *const RCTProfileDidEndProfiling;
#if RCT_DEV
#define RCTProfileBeginFlowEvent() \

View File

@@ -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;