Allow additional information to be passed to systrace events

Summary: Expose the ability to provide extra information to Systrace events from JS. This is specifically useful for instrumenting generic recursive method that are defined completely through their params.

Reviewed By: tadeuzagallo

Differential Revision: D3423595

fbshipit-source-id: 7f2dedf02bf901401a6b391b85b1a0bb6782349c
This commit is contained in:
Pieter De Baets 2016-06-13 04:18:33 -07:00 committed by Facebook Github Bot 5
parent d7fc58f32c
commit c25e48abfc
2 changed files with 4 additions and 4 deletions

View File

@ -66,11 +66,11 @@ const Systrace = {
/**
* beginEvent/endEvent for starting and then ending a profile within the same call stack frame
**/
beginEvent(profileName?: any) {
beginEvent(profileName?: any, args?: any) {
if (_enabled) {
profileName = typeof profileName === 'function' ?
profileName() : profileName;
global.nativeTraceBeginSection(TRACE_TAG_REACT_APPS, profileName);
global.nativeTraceBeginSection(TRACE_TAG_REACT_APPS, profileName, args);
}
},

View File

@ -415,13 +415,13 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
CFDictionaryRemoveValue(strongSelf->_cookieMap, (const void *)cookie);
}];
[self addSynchronousHookWithName:@"nativeTraceBeginSection" usingBlock:^(NSNumber *tag, NSString *profileName){
[self addSynchronousHookWithName:@"nativeTraceBeginSection" usingBlock:^(NSNumber *tag, NSString *profileName, NSDictionary *args) {
static int profileCounter = 1;
if (!profileName) {
profileName = [NSString stringWithFormat:@"Profile %d", profileCounter++];
}
RCT_PROFILE_BEGIN_EVENT(tag.longLongValue, profileName, nil);
RCT_PROFILE_BEGIN_EVENT(tag.longLongValue, profileName, args);
}];
[self addSynchronousHookWithName:@"nativeTraceEndSection" usingBlock:^(NSNumber *tag) {