Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[iOS] add fake performance detail data for server test (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianhan-he authored and lucky-chen committed Aug 1, 2019
1 parent dc63c56 commit cf31bc0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 8 deletions.
6 changes: 3 additions & 3 deletions ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,10 @@ - (void)_sendQueueLoop
} else {
[self callJSMethod:@"callJS" args:@[execIns, [tasks copy]]];
}
if (execInstance && !(execInstance.isJSCreateFinish)) {
if (execInstance) {
NSTimeInterval diff = CACurrentMediaTime()*1000 - start;
execInstance.performance.fsCallJsNum++;
execInstance.performance.fsCallJsTime = execInstance.performance.fsCallJsTime+ diff;
execInstance.performance.callJsNum++;
execInstance.performance.callJsTime = execInstance.performance.callJsTime+ diff;
}
if (execInstance && !execInstance.apmInstance.isFSEnd) {
NSTimeInterval diff = CACurrentMediaTime()*1000 - start;
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ - (UIView *)view
return _view;
} else {
WXAssertMainThread();
double startCreateViewTime = CACurrentMediaTime()*1000;

// compositing child will be drew by its composited ancestor
if (_isCompositingChild) {
Expand Down Expand Up @@ -446,6 +447,8 @@ - (UIView *)view
[self _buildViewHierarchyLazily];
}

double diffTime = CACurrentMediaTime()*1000 - startCreateViewTime;
[self.weexInstance.performance recordViewCreatePerformance:diffTime];
[self _handleFirstScreenTime];

[self.weexInstance.performance onViewLoad:self];
Expand Down
7 changes: 5 additions & 2 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
@property (nonatomic, assign) double jsCreateFinishTime;

//firsrScreen call jsMethod totalTime
@property (nonatomic, assign) double fsCallJsTime;
@property (nonatomic, assign) double callJsTime;
//firsrScreen call jsMethod totalNum
@property (nonatomic, assign) double fsCallJsNum;
@property (nonatomic, assign) double callJsNum;
//firsrScreen call nativeMethod totalTime
@property (nonatomic, assign) double fsCallNativeTime;
//firsrScreen call nativeMethod totalNum
Expand Down Expand Up @@ -61,12 +61,15 @@
//all componentCreate time in instance life
@property (nonatomic,assign) double componentCreateTime;

@property (nonatomic,assign) double viewCreateTime;

@property (nonatomic,assign) double newFsRenderTime;
@property (nonatomic,assign) long lastRealInteractionTime;
//for performance record

- (void)onViewLoad:(WXComponent *)targetComponent;
- (void)recordComponentCreatePerformance:(double) diffTime forComponent:(WXComponent *)targetComponent;
- (void)recordViewCreatePerformance:(double) diffTime;
- (void)onInstanceRenderSuccess:(WXSDKInstance*) instance;

@end
Expand Down
12 changes: 10 additions & 2 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ - (void) recordComponentCreatePerformance:(double) diffTime forComponent:(WXComp
self.componentCreateTime+=diffTime;
}

- (void)recordViewCreatePerformance:(double) diffTime {
self.viewCreateTime += diffTime;
}

/** on UI thread **/
- (void)onViewLoad:(WXComponent *)targetComponent
{
Expand Down Expand Up @@ -124,6 +128,10 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent withModifyTime:(double)
self.interactionAddCount = self.interactionAddCountRecord;
[targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_I_SCREEN_VIEW_COUNT curMaxValue:self.interactionLimitAddOpCount];
[targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_I_ALL_VIEW_COUNT curMaxValue:self.interactionAddCount];
[targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_EXECUTE_JS_TIME curMaxValue:self.callJsTime];
[targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_CREATE_COMPONENT_TIME curMaxValue:self.componentCreateTime];
[targetComponent.weexInstance.apmInstance updateMaxStats:KEY_PAGE_STATS_CREATE_VIEW_TIME curMaxValue:self.viewCreateTime];

self.interactionTime = self.interactionTime < diff ? diff :self.interactionTime;
}

Expand Down Expand Up @@ -186,8 +194,8 @@ - (void) updatePerDicAfterCreateFinish
[WXMonitor performanceFinishWithState:DebugAfterFSFinish instance:self];
self.performance.jsCreateFinishTime = CACurrentMediaTime()*1000;
self.isJSCreateFinish = TRUE;
WX_MONITOR_PERF_SET(WXPTFsCallJsNum, self.performance.fsCallJsNum, self);
WX_MONITOR_PERF_SET(WXPTFsCallJsTime, self.performance.fsCallJsTime, self);
WX_MONITOR_PERF_SET(WXPTFsCallJsNum, self.performance.callJsNum, self);
WX_MONITOR_PERF_SET(WXPTFsCallJsTime, self.performance.callJsTime, self);
WX_MONITOR_PERF_SET(WXPTFsCallNativeNum, self.performance.fsCallNativeNum, self);
WX_MONITOR_PERF_SET(WXPTFsCallNativeTime, self.performance.fsCallNativeTime, self);
WX_MONITOR_PERF_SET(WXPTFsReqNetNum, self.performance.fsReqNetNum, self);
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ extern NSString* const KEY_PAGE_STAGES_DESTROY;
extern NSString* const KEY_PAGE_STATS_BUNDLE_SIZE;
extern NSString* const KEY_PAGE_STATS_FS_CALL_JS_TIME;
extern NSString* const KEY_PAGE_STATS_FS_CALL_JS_NUM;
extern NSString* const KEY_PAGE_STATS_EXECUTE_JS_TIME;
extern NSString* const KEY_PAGE_STATS_CREATE_COMPONENT_TIME;
extern NSString* const KEY_PAGE_STATS_CREATE_VIEW_TIME;
extern NSString* const KEY_PAGE_STATS_FS_TIMER_NUM;
extern NSString* const KEY_PAGE_STATS_FS_CALL_NATIVE_TIME;
extern NSString* const KEY_PAGE_STATS_FS_CALL_NATIVE_NUM;
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
NSString* const KEY_PAGE_STATS_BUNDLE_SIZE = @"wxBundleSize";
NSString* const KEY_PAGE_STATS_FS_CALL_JS_TIME = @"wxFSCallJsTotalTime";
NSString* const KEY_PAGE_STATS_FS_CALL_JS_NUM = @"wxFSCallJsTotalNum";
NSString* const KEY_PAGE_STATS_EXECUTE_JS_TIME = @"wxExecJsCallBack";
NSString* const KEY_PAGE_STATS_CREATE_COMPONENT_TIME = @"wxComponentCost";
NSString* const KEY_PAGE_STATS_CREATE_VIEW_TIME = @"wxViewCost";
NSString* const KEY_PAGE_STATS_FS_TIMER_NUM = @"wxFSTimerCount";
NSString* const KEY_PAGE_STATS_FS_CALL_NATIVE_TIME = @"wxFSCallNativeTotalTime";
NSString* const KEY_PAGE_STATS_FS_CALL_NATIVE_NUM = @"wxFSCallNativeTotalNum";
Expand Down
2 changes: 1 addition & 1 deletion weex_core/Source/base/log_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class LogImplement {

#else
#define LOGD_TAG(TAG, format, ...) ((void) 0)
#define LOGD(format, ...) if(weex::base::LogImplement::getLog()->debugMode()) WEEX_CORE_LOG(WeexCore::LogLevel::Debug, TAG, format, ##__VA_ARGS__)
#define LOGD(format, ...) ((void) 0)

#endif

Expand Down

0 comments on commit cf31bc0

Please sign in to comment.