+ [ios] add performance for first excute js and optimize prerender

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/3ec14843
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/3ec14843
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/3ec14843

Branch: refs/heads/0.16-dev
Commit: 3ec148430d5b452246f8836b181535597d3122fd
Parents: 3c2ce63
Author: 齐山 <sunjjb...@163.com>
Authored: Wed Sep 6 23:26:59 2017 +0800
Committer: 齐山 <sunjjb...@163.com>
Committed: Wed Sep 6 23:26:59 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Bridge/WXBridgeContext.m    |  4 ++--
 .../Sources/Manager/WXComponentManager.m        |  1 +
 .../WeexSDK/Sources/Module/WXPrerenderManager.m | 20 +++++++++-----------
 ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.h     |  1 +
 ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m     |  3 ++-
 .../Sources/Protocol/WXAppMonitorProtocol.h     |  1 +
 6 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3ec14843/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m 
b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index ca57dc2..7985fe5 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -441,7 +441,7 @@ _Pragma("clang diagnostic pop") \
     } else {
         args = @[instance, temp, options ?: @{}];
     }
-
+    WX_MONITOR_INSTANCE_PERF_START(WXFirstScreenJSFExecuteTime, [WXSDKManager 
instanceForID:instance]);
     WX_MONITOR_INSTANCE_PERF_START(WXPTJSCreateInstance, [WXSDKManager 
instanceForID:instance]);
     [self callJSMethod:@"createInstance" args:args];
     WX_MONITOR_INSTANCE_PERF_END(WXPTJSCreateInstance, [WXSDKManager 
instanceForID:instance]);
@@ -500,7 +500,7 @@ _Pragma("clang diagnostic pop") \
     WXAssertParam(script);
     
     WX_MONITOR_PERF_START(WXPTFrameworkExecute);
-    
+
     [self.jsBridge executeJSFramework:script];
     
     WX_MONITOR_PERF_END(WXPTFrameworkExecute);

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3ec14843/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m 
b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
index 86ec447..55784b3 100644
--- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
+++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.m
@@ -205,6 +205,7 @@ static NSThread *WXComponentThread;
     
     [self _initRootCSSNode];
     __weak typeof(self) weakSelf = self;
+    WX_MONITOR_INSTANCE_PERF_END(WXFirstScreenJSFExecuteTime, 
self.weexInstance);
     [self _addUITask:^{
         [WXTracingManager 
startTracingWithInstanceId:weakSelf.weexInstance.instanceId ref:data[@"ref"] 
className:nil name:data[@"type"] phase:WXTracingBegin 
functionName:@"createBody" options:@{@"threadName":WXTUIThread}];
         __strong typeof(self) strongSelf = weakSelf;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3ec14843/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m 
b/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m
index d7d51bd..90f1c7f 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXPrerenderManager.m
@@ -168,19 +168,15 @@ static NSString *const MSG_PRERENDER_SUCCESS = @"success";
             self.maxCacheNumber = max;
         }
     }
-    
-    
-    WXSDKInstance *instance = [[WXSDKInstance alloc] init];
-    instance.needPrerender = YES;
-    task.instance = instance;
-    task.parentInstanceId = instanceId;
-    task.url = url.absoluteString;
-    task.isCache = isCache;
-    
     if(self.prerenderTasks && self.prerenderTasks.count<self.maxCacheNumber){
         [self.prerenderTasks setObject:task forKey:[WXPrerenderManager 
getTaskKeyFromUrl:url.absoluteString]];
         WXPerformBlockOnMainThread(^{
-            [instance renderWithURL:url 
options:@{@"bundleUrl":url.absoluteString} data:nil];
+            WXSDKInstance *instance = [[WXSDKInstance alloc] init];
+            instance.needPrerender = YES;
+            task.instance = instance;
+            task.parentInstanceId = instanceId;
+            task.url = url.absoluteString;
+            task.isCache = isCache;
             WXPrerenderManager *manager = [WXPrerenderManager sharedInstance];
             __weak typeof(self) weakSelf = manager;
             instance.onCreate = ^(UIView *view) {
@@ -198,6 +194,7 @@ static NSString *const MSG_PRERENDER_SUCCESS = @"success";
                     [weakSelf.prerenderTasks setObject:task 
forKey:[WXPrerenderManager getTaskKeyFromUrl:url.absoluteString]];
                 }
             };
+            [instance renderWithURL:url 
options:@{@"bundleUrl":url.absoluteString} data:nil];
         });
         if(callback){
             
callback(@{@"url":url.absoluteString,@"message":MSG_PRERENDER_SUCCESS,@"result":@"success"});
@@ -237,7 +234,8 @@ static NSString *const MSG_PRERENDER_SUCCESS = @"success";
 }
 
 + (BOOL)isTaskExist:(NSString *)url{
-    return [[WXPrerenderManager sharedInstance]isTaskExist:url];
+    
+    return [[WXPrerenderManager sharedInstance] isTaskExist:url];
 }
 
 - (BOOL)isTaskExist:(NSString *)url

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3ec14843/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.h 
b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.h
index 60b6c6e..4ec0c07 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.h
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.h
@@ -31,6 +31,7 @@ typedef enum : NSUInteger {
     // instance
     WXPTJSDownload,
     WXPTJSCreateInstance,
+    WXFirstScreenJSFExecuteTime,
     WXPTFirstScreenRender,
     WXPTAllRender,
     WXPTBundleSize,

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3ec14843/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m 
b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
index aadb411..f05cac5 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
@@ -139,9 +139,10 @@ static WXThreadSafeMutableDictionary 
*globalPerformanceDict;
                           @(WXPTFrameworkExecute) : JSLIBINITTIME,
                           @(WXPTJSDownload) : NETWORKTIME,
                           @(WXPTJSCreateInstance) : COMMUNICATETIME,
+                          @(WXFirstScreenJSFExecuteTime) : 
FIRSETSCREENJSFEXECUTETIME,
                           @(WXPTFirstScreenRender) : SCREENRENDERTIME,
                           @(WXPTAllRender) : TOTALTIME,
-                          @(WXPTBundleSize) : JSTEMPLATESIZE
+                          @(WXPTBundleSize) : JSTEMPLATESIZE,
                           };
     });
     

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/3ec14843/ios/sdk/WeexSDK/Sources/Protocol/WXAppMonitorProtocol.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Protocol/WXAppMonitorProtocol.h 
b/ios/sdk/WeexSDK/Sources/Protocol/WXAppMonitorProtocol.h
index 761ba8e..74031c9 100644
--- a/ios/sdk/WeexSDK/Sources/Protocol/WXAppMonitorProtocol.h
+++ b/ios/sdk/WeexSDK/Sources/Protocol/WXAppMonitorProtocol.h
@@ -35,6 +35,7 @@
 #define COMMUNICATETIME     @"communicateTime"
 #define SCREENRENDERTIME    @"screenRenderTime"
 #define TOTALTIME           @"totalTime"
+#define FIRSETSCREENJSFEXECUTETIME  @"firstScreenJSFExecuteTime"
 
 #define CACHEPROCESSTIME    @"cacheProcessTime"
 #define CACHERATIO          @"cacheRatio"

Reply via email to