From e5b843834dfbe203952f5321f1e7fd0be1bd1d44 Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Mon, 9 Nov 2015 08:42:51 -0800 Subject: [PATCH] Rename RCTProfile(Begin|End)Event Summary: public Rename it to `RCT_PROFILE_(BEGIN|END)_EVENT` to make it clearer that it's a macro, since it has special behaviours. Reviewed By: jspahrsummers Differential Revision: D2631542 fb-gh-sync-id: 629c139462c4aa3582f719b14482017d13676e33 --- React/Base/RCTBatchedBridge.m | 20 ++++++++++---------- React/Executors/RCTContextExecutor.m | 4 ++-- React/Modules/RCTUIManager.m | 4 ++-- React/Profiler/RCTProfile.h | 15 +++++++++------ React/Profiler/RCTProfile.m | 4 ++-- 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 871d54eac..18d6da49b 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -592,13 +592,13 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR return; } - RCTProfileBeginEvent(0, @"FetchApplicationScriptCallbacks", nil); + RCT_PROFILE_BEGIN_EVENT(0, @"FetchApplicationScriptCallbacks", nil); [_javaScriptExecutor executeJSCall:@"BatchedBridge" method:@"flushedQueue" arguments:@[] callback:^(id json, NSError *error) { - RCTProfileEndEvent(0, @"js_call,init", @{ + RCT_PROFILE_END_EVENT(0, @"js_call,init", @{ @"json": RCTNullIfNil(json), @"error": RCTNullIfNil(error), }); @@ -733,7 +733,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR #if RCT_DEV NSString *_threadName = RCTCurrentThreadName(); - RCTProfileBeginEvent(0, _threadName, nil); + RCT_PROFILE_BEGIN_EVENT(0, _threadName, nil); #endif NSOrderedSet *calls = [buckets objectForKey:queue]; @@ -747,7 +747,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR } } - RCTProfileEndEvent(0, @"objc_call,dispatch_async", @{ + RCT_PROFILE_END_EVENT(0, @"objc_call,dispatch_async", @{ @"calls": @(calls.count), }); }; @@ -798,7 +798,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR return NO; } - RCTProfileBeginEvent(0, [NSString stringWithFormat:@"[%@ %@]", moduleData.name, method.JSMethodName], nil); + RCT_PROFILE_BEGIN_EVENT(0, [NSString stringWithFormat:@"[%@ %@]", moduleData.name, method.JSMethodName], nil); @try { [method invokeWithBridge:self module:moduleData.instance arguments:params]; @@ -819,7 +819,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR NSMutableDictionary *args = [method.profileArgs mutableCopy]; args[@"method"] = method.JSMethodName; args[@"args"] = RCTJSONStringify(RCTNullIfNil(params), NULL); - RCTProfileEndEvent(0, @"objc_call", args); + RCT_PROFILE_END_EVENT(0, @"objc_call", args); } return YES; @@ -828,7 +828,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR - (void)_jsThreadUpdate:(CADisplayLink *)displayLink { RCTAssertJSThread(); - RCTProfileBeginEvent(0, @"DispatchFrameUpdate", nil); + RCT_PROFILE_BEGIN_EVENT(0, @"DispatchFrameUpdate", nil); RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink]; for (RCTModuleData *moduleData in _frameUpdateObservers) { @@ -839,9 +839,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR [moduleData dispatchBlock:^{ RCTProfileEndFlowEvent(); - RCTProfileBeginEvent(0, name, nil); + RCT_PROFILE_BEGIN_EVENT(0, name, nil); [observer didUpdateFrame:frameUpdate]; - RCTProfileEndEvent(0, @"objc_call,fps", nil); + RCT_PROFILE_END_EVENT(0, @"objc_call,fps", nil); }]; } } @@ -851,7 +851,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR RCTProfileImmediateEvent(0, @"JS Thread Tick", 'g'); - RCTProfileEndEvent(0, @"objc_call", nil); + RCT_PROFILE_END_EVENT(0, @"objc_call", nil); } - (void)startProfiling diff --git a/React/Executors/RCTContextExecutor.m b/React/Executors/RCTContextExecutor.m index 53e0b2ad9..59c702025 100644 --- a/React/Executors/RCTContextExecutor.m +++ b/React/Executors/RCTContextExecutor.m @@ -192,7 +192,7 @@ static JSValueRef RCTNativeTraceBeginSection(JSContextRef context, __unused JSOb } if (profileName) { - RCTProfileBeginEvent(tag, profileName, nil); + RCT_PROFILE_BEGIN_EVENT(tag, profileName, nil); } return JSValueMakeUndefined(context); @@ -202,7 +202,7 @@ static JSValueRef RCTNativeTraceEndSection(JSContextRef context, __unused JSObje { if (argumentCount > 0) { double tag = JSValueToNumber(context, arguments[0], exception); - RCTProfileEndEvent((uint64_t)tag, @"console", nil); + RCT_PROFILE_END_EVENT((uint64_t)tag, @"console", nil); } return JSValueMakeUndefined(context); diff --git a/React/Modules/RCTUIManager.m b/React/Modules/RCTUIManager.m index 0f675a518..c76ee7e79 100644 --- a/React/Modules/RCTUIManager.m +++ b/React/Modules/RCTUIManager.m @@ -909,7 +909,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po RCTProfileBeginFlowEvent(); dispatch_async(dispatch_get_main_queue(), ^{ RCTProfileEndFlowEvent(); - RCTProfileBeginEvent(0, @"UIManager flushUIBlocks", nil); + RCT_PROFILE_BEGIN_EVENT(0, @"UIManager flushUIBlocks", nil); @try { for (dispatch_block_t block in previousPendingUIBlocks) { block(); @@ -924,7 +924,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po @catch (NSException *exception) { RCTLogError(@"Exception thrown while executing UI block: %@", exception); } - RCTProfileEndEvent(0, @"objc_call", @{ + RCT_PROFILE_END_EVENT(0, @"objc_call", @{ @"count": @(previousPendingUIBlocks.count), }); }); diff --git a/React/Profiler/RCTProfile.h b/React/Profiler/RCTProfile.h index addddf3df..5829a8eb4 100644 --- a/React/Profiler/RCTProfile.h +++ b/React/Profiler/RCTProfile.h @@ -66,7 +66,7 @@ RCT_EXTERN void _RCTProfileBeginEvent(NSThread *calleeThread, uint64_t tag, NSString *name, NSDictionary *args); -#define RCTProfileBeginEvent(...) { \ +#define RCT_PROFILE_BEGIN_EVENT(...) { \ NSThread *calleeThread = [NSThread currentThread]; \ NSTimeInterval time = CACurrentMediaTime(); \ dispatch_async(RCTProfileGetQueue(), ^{ \ @@ -86,7 +86,7 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread, NSString *category, NSDictionary *args); -#define RCTProfileEndEvent(...) { \ +#define RCT_PROFILE_END_EVENT(...) { \ NSThread *calleeThread = [NSThread currentThread]; \ NSString *threadName = RCTCurrentThreadName(); \ NSTimeInterval time = CACurrentMediaTime(); \ @@ -128,9 +128,9 @@ RCT_EXTERN void RCTProfileImmediateEvent(uint64_t tag, */ #define RCTProfileBlock(block, tag, category, arguments) \ ^{ \ - RCTProfileBeginEvent(tag, @(__PRETTY_FUNCTION__), nil); \ + RCT_PROFILE_BEGIN_EVENT(tag, @(__PRETTY_FUNCTION__), nil); \ block(); \ - RCTProfileEndEvent(tag, category, arguments); \ + RCT_PROFILE_END_EVENT(tag, category, arguments); \ } /** @@ -189,8 +189,11 @@ RCT_EXTERN void RCTProfileRegisterCallbacks(RCTProfileCallbacks *); #define RCTProfileInit(...) #define RCTProfileEnd(...) @"" -#define RCTProfileBeginEvent(...) -#define RCTProfileEndEvent(...) +#define _RCTProfileBeginEvent(...) +#define _RCTProfileEndEvent(...) + +#define RCT_PROFILE_BEGIN_EVENT(...) +#define RCT_PROFILE_END_EVENT(...) #define RCTProfileBeginAsyncEvent(...) 0 #define RCTProfileEndAsyncEvent(...) diff --git a/React/Profiler/RCTProfile.m b/React/Profiler/RCTProfile.m index b2ce5b87a..40c5a3502 100644 --- a/React/Profiler/RCTProfile.m +++ b/React/Profiler/RCTProfile.m @@ -190,13 +190,13 @@ RCT_EXTERN void RCTProfileTrampolineStart(id, SEL); void RCTProfileTrampolineStart(id self, SEL cmd) { NSString *name = [NSString stringWithFormat:@"-[%s %s]", class_getName([self class]), sel_getName(cmd)]; - RCTProfileBeginEvent(0, name, nil); + RCT_PROFILE_BEGIN_EVENT(0, name, nil); } RCT_EXTERN void RCTProfileTrampolineEnd(void); void RCTProfileTrampolineEnd(void) { - RCTProfileEndEvent(0, @"objc_call,modules,auto", nil); + RCT_PROFILE_END_EVENT(0, @"objc_call,modules,auto", nil); } void RCTProfileHookModules(RCTBridge *bridge)