Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(perf): enable perflog output in debug mode only #3564

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions framework/ios/base/bridge/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ - (instancetype)initWithDelegate:(id<HippyBridgeDelegate>)delegate
_valid = YES;
_bundlesQueue = [[HippyBundleOperationQueue alloc] init];
_startTime = footstone::TimePoint::SystemNow();
HP_PERF_LOG("HippyBridge init begin, self:%p", self);
HippyLogInfo(@"HippyBridge init begin, self:%p", self);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rootViewContentDidAppear:)
name:HippyContentDidAppearNotification object:nil];
HippyExecuteOnMainThread(^{
Expand All @@ -208,7 +208,7 @@ - (instancetype)initWithDelegate:(id<HippyBridgeDelegate>)delegate
[HippyBridge setCurrentBridge:self];

[self loadPendingVendorBundleURLIfNeeded];
HP_PERF_LOG("HippyBridge init end, self:%p", self);
HippyLogInfo(@"HippyBridge init end, self:%p", self);
}
return self;
}
Expand Down Expand Up @@ -414,7 +414,7 @@ - (void)loadBundleURL:(NSURL *)bundleURL
}
return;
}
HP_PERF_LOG("Begin loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));
HippyLogInfo(@"Begin loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));
[_bundleURLs addObject:bundleURL];
dispatch_async(HippyBridgeQueue(), ^{
[self beginLoadingBundle:bundleURL completion:completion];
Expand Down Expand Up @@ -452,7 +452,7 @@ - (void)beginLoadingBundle:(NSURL *)bundleURL
return;
}
[strongSelf executeJSCode:script sourceURL:bundleURL onCompletion:^(id result, NSError *error) {
HP_PERF_LOG("End loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));
HippyLogInfo(@"End loading bundle(%s) at %s", HP_CSTR_NOT_NULL(bundleURL.absoluteString.lastPathComponent.UTF8String), HP_CSTR_NOT_NULL(bundleURL.absoluteString.UTF8String));

if (completion) {
completion(bundleURL, error);
Expand Down Expand Up @@ -509,15 +509,15 @@ - (void)loadInstanceForRootView:(NSNumber *)rootTag withProperties:(NSDictionary
- (void)innerLoadInstanceForRootView:(NSNumber *)rootTag withProperties:(NSDictionary *)props {
HippyAssert(_moduleName, @"module name must not be null");
HippyLogInfo(@"[Hippy_OC_Log][Life_Circle],Running application %@ (%@)", _moduleName, props);
HP_PERF_LOG("Begin loading instance for HippyBridge(%p)", self);
HippyLogInfo(@"Begin loading instance for HippyBridge(%p)", self);
NSDictionary *param = @{@"name": _moduleName,
@"id": rootTag,
@"params": props ?: @{},
@"version": HippySDKVersion};
footstone::value::HippyValue value = [param toHippyValue];
std::shared_ptr<footstone::value::HippyValue> domValue = std::make_shared<footstone::value::HippyValue>(value);
self.javaScriptExecutor.pScope->LoadInstance(domValue);
HP_PERF_LOG("End loading instance for HippyBridge(%p)", self);
HippyLogInfo(@"End loading instance for HippyBridge(%p)", self);
}

- (void)rootViewSizeChangedEvent:(NSNumber *)tag params:(NSDictionary *)params {
Expand Down
9 changes: 9 additions & 0 deletions modules/footstone/include/footstone/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,16 @@ bool ShouldCreateLogMessage(LogSeverity severity);


#define HP_CSTR_NOT_NULL( p ) (p ? p : "")

#ifdef DEBUG
ruifanyuan marked this conversation as resolved.
Show resolved Hide resolved

// enable perf log output in debug mode only
#define HP_PERF_LOG(format, ...) \
footstone::LogMessage::LogWithFormat(__FILE_NAME__, __LINE__, "[HP PERF] " format, \
##__VA_ARGS__)

#else

#define HP_PERF_LOG(format, ...)

#endif
Loading