mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-25 21:05:40 +08:00
Expose JS hooks to profile async events
Summary: public Expose JS hooks to add async events to Systrace from JS. Reviewed By: mikearmstrong001 Differential Revision: D2702739 fb-gh-sync-id: 906849d3819a914c521b9315e396c75946c9211d
This commit is contained in:
committed by
facebook-github-bot-7
parent
7377fdcc70
commit
8ec052a727
@@ -352,7 +352,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
||||
[bridge handleBuffer:calls batchEnded:NO];
|
||||
};
|
||||
|
||||
strongSelf->_context.context[@"RCTPerformanceNow"] = ^(){
|
||||
strongSelf->_context.context[@"RCTPerformanceNow"] = ^{
|
||||
return CACurrentMediaTime() * 1000 * 1000;
|
||||
};
|
||||
|
||||
@@ -361,6 +361,20 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
||||
strongSelf->_context.context[@"__RCTProfileIsProfiling"] = @YES;
|
||||
}
|
||||
|
||||
CFMutableDictionaryRef cookieMap = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
|
||||
strongSelf->_context.context[@"nativeTraceBeginAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
||||
NSUInteger newCookie = RCTProfileBeginAsyncEvent(tag, name, nil);
|
||||
CFDictionarySetValue(cookieMap, (const void *)cookie, (const void *)newCookie);
|
||||
return;
|
||||
};
|
||||
|
||||
strongSelf->_context.context[@"nativeTraceEndAsyncSection"] = ^(uint64_t tag, NSString *name, NSUInteger cookie) {
|
||||
NSUInteger newCookie = (NSUInteger)CFDictionaryGetValue(cookieMap, (const void *)cookie);
|
||||
RCTProfileEndAsyncEvent(tag, @"js,async", newCookie, name, nil);
|
||||
CFDictionaryRemoveValue(cookieMap, (const void *)cookie);
|
||||
return;
|
||||
};
|
||||
|
||||
[strongSelf _addNativeHook:RCTNativeTraceBeginSection withName:"nativeTraceBeginSection"];
|
||||
[strongSelf _addNativeHook:RCTNativeTraceEndSection withName:"nativeTraceEndSection"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user