com.taobao.weex.common.WXPerformance Java Examples
The following examples show how to use
com.taobao.weex.common.WXPerformance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 6 votes |
public void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg) { WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); if (instance == null || errCode == null) { return; } // TODO: We should move WXPerformance and IWXUserTrackAdapter // into a adapter level. // comment out the line below to prevent commiting twice. //instance.commitUTStab(WXConst.JS_BRIDGE, errCode, errMsg); IWXUserTrackAdapter adapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if (adapter == null) { return; } WXPerformance performance = new WXPerformance(); performance.args=instance.getBundleUrl(); performance.errCode=errCode.getErrorCode(); if (errCode != WXErrorCode.WX_SUCCESS) { performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errCode.getErrorMsg():errMsg); WXLogUtils.e("wx_monitor",performance.toString()); } adapter.commit(WXEnvironment.getApplication(), null, IWXUserTrackAdapter.JS_BRIDGE, performance, instance.getUserTrackParams()); }
Example #2
Source File: WXBridgeManager.java From ucar-weex-core with Apache License 2.0 | 6 votes |
public void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg) { if (TextUtils.isEmpty(type) || errorCode == null) { return; } if (WXSDKManager.getInstance().getWXStatisticsListener() != null) { WXSDKManager.getInstance().getWXStatisticsListener().onException("0", errorCode.getErrorCode(), TextUtils.isEmpty(errMsg) ? errorCode.getErrorMsg() : errMsg); } final IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if (userTrackAdapter == null) { return; } WXPerformance performance = new WXPerformance(); performance.errCode = errorCode.getErrorCode(); if (errorCode != WXErrorCode.WX_SUCCESS) { performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errorCode.getErrorMsg():errMsg); WXLogUtils.e("wx_monitor",performance.toString()); } userTrackAdapter.commit(WXEnvironment.getApplication(), null, type, performance, null); }
Example #3
Source File: WXSoInstallMgrSdk.java From ucar-weex-core with Apache License 2.0 | 6 votes |
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) { if (mStatisticsListener != null) { mStatisticsListener.onException("0", errCode, errMsg); } if (utAdapter == null) { return; } if (errCode != null && errMsg != null) { WXPerformance p = new WXPerformance(); p.errCode = errCode; p.errMsg = errMsg; utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, p, null); } else { utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, null, null); } }
Example #4
Source File: WXSDKInstance.java From weex-uikit with MIT License | 6 votes |
/** * UserTrack Log */ public void commitUTStab(final String type, final WXErrorCode errorCode) { if (mUserTrackAdapter == null || TextUtils.isEmpty(type) || errorCode==null) { return; } runOnUiThread(new Runnable() { @Override public void run() { WXPerformance performance = new WXPerformance(); performance.errCode = errorCode.getErrorCode(); performance.args = errorCode.getArgs(); if (errorCode != WXErrorCode.WX_SUCCESS) { performance.errMsg = errorCode.getErrorMsg(); if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(performance.toString()); } } if( mUserTrackAdapter!= null) { mUserTrackAdapter.commit(mContext, null, type, performance, getUserTrackParams()); } } }); }
Example #5
Source File: WXSDKInstance.java From weex-uikit with MIT License | 6 votes |
private String wrapPageName(String pageName, String url) { if(TextUtils.equals(pageName, WXPerformance.DEFAULT)){ pageName=url; try { Uri uri=Uri.parse(url); if(uri!=null){ Uri.Builder builder=new Uri.Builder(); builder.scheme(uri.getScheme()); builder.authority(uri.getAuthority()); builder.path(uri.getPath()); pageName=builder.toString(); } } catch (Exception e) { } } return pageName; }
Example #6
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 6 votes |
private String wrapPageName(String pageName, String url) { if(TextUtils.equals(pageName, WXPerformance.DEFAULT)){ pageName=url; try { Uri uri=Uri.parse(url); if(uri!=null){ Uri.Builder builder=new Uri.Builder(); builder.scheme(uri.getScheme()); builder.authority(uri.getAuthority()); builder.path(uri.getPath()); pageName=builder.toString(); } } catch (Exception e) { } } return pageName; }
Example #7
Source File: BenchmarkTest.java From incubator-weex-playground with Apache License 2.0 | 6 votes |
@Test public void testFirstScreenPerformance() { List<Long> localTotalTime = new ArrayList<>(TIMES); List<Long> localLayoutTime = new ArrayList<>(TIMES); for (int i = 0; i < TIMES; i++) { WXPerformance performance = fetchPerformance(); long currentTime = performance.screenRenderTime; long layoutTime = performance.cssLayoutTime; localTotalTime.add(currentTime); localLayoutTime.add(layoutTime); Log.d(TAG, "FIRST_SCREEN_RENDER_TIME (activity not kill) " + currentTime + "ms"); Log.d(TAG, "FIRST_SCREEN_LAYOUT_TIME (activity not kill) " + layoutTime + "ms"); } BoxPlot render = new BoxPlot(localTotalTime); BoxPlot layout = new BoxPlot(localLayoutTime); Log.i(TAG, "Average firstScreenRenderTime (activity not kill) " + render.draw()); Log.i(TAG, "Average firstScreenLayoutTime (activity not kill) " + layout.draw()); assertThat(render.getAverage(), Matchers.lessThan(FIRST_SCREEN_RENDER_TIME)); }
Example #8
Source File: WXBridgeManager.java From weex-uikit with MIT License | 5 votes |
public void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg) { final IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if (userTrackAdapter == null || TextUtils.isEmpty(type) || errorCode == null) { return; } WXPerformance performance = new WXPerformance(); performance.errCode = errorCode.getErrorCode(); if (errorCode != WXErrorCode.WX_SUCCESS) { performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errorCode.getErrorMsg():errMsg); WXLogUtils.e("wx_monitor",performance.toString()); } userTrackAdapter.commit(WXEnvironment.getApplication(), null, type, performance, null); }
Example #9
Source File: WXSDKInstance.java From weex with Apache License 2.0 | 5 votes |
/** * UserTrack Log */ public void commitUTStab(final String type, final WXErrorCode errorCode) { if (errorCode == WXErrorCode.WX_SUCCESS) { return; } runOnUiThread(new Runnable() { @Override public void run() { if (mUserTrackAdapter == null || TextUtils.isEmpty(type)) { return; } // Log for commit if (errorCode.getErrorCode() == null && errorCode.getErrorMsg() == null) { mUserTrackAdapter.commit(mContext, null, type, null, null); return; } WXPerformance perf = new WXPerformance(); perf.errCode = errorCode.getErrorCode(); perf.errMsg = errorCode.getErrorMsg(); if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(perf.toString()); } mUserTrackAdapter.commit(mContext, null, type, perf, null); } }); }
Example #10
Source File: WXSDKInstance.java From weex with Apache License 2.0 | 5 votes |
public void init(Context context) { mContext = context; mWXPerformance = new WXPerformance(); mWXPerformance.WXSDKVersion = WXEnvironment.WXSDK_VERSION; mWXPerformance.JSLibInitTime = WXEnvironment.sJSLibInitTime; mUserTrackAdapter=WXSDKManager.getInstance().getIWXUserTrackAdapter(); mWXHttpAdapter=WXSDKManager.getInstance().getIWXHttpAdapter(); }
Example #11
Source File: WXSoInstallMgrSdk.java From weex with Apache License 2.0 | 5 votes |
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) { if (utAdapter == null) { return; } if (errCode != null && errMsg != null) { WXPerformance p = new WXPerformance(); p.errCode = errCode; p.errMsg = errMsg; utAdapter.commit(null, null, WXConst.ENVIRONMENT, p, null); } else { utAdapter.commit(null, null, WXConst.ENVIRONMENT, null, null); } }
Example #12
Source File: PerformanceMonitor.java From analyzer-of-android-for-Apache-Weex with Apache License 2.0 | 5 votes |
private static Performance filter(@NonNull WXPerformance rawPerformance) { Performance p = new Performance(); p.localReadTime = rawPerformance.localReadTime; p.JSLibSize = rawPerformance.JSLibSize; p.JSLibInitTime = rawPerformance.JSLibInitTime; p.JSTemplateSize = rawPerformance.JSTemplateSize; p.templateLoadTime = rawPerformance.templateLoadTime; p.communicateTime = rawPerformance.communicateTime; p.screenRenderTime = rawPerformance.screenRenderTime; p.callNativeTime = rawPerformance.callNativeTime; p.firstScreenJSFExecuteTime = rawPerformance.firstScreenJSFExecuteTime; p.batchTime = rawPerformance.batchTime; p.parseJsonTime = rawPerformance.parseJsonTime; p.updateDomObjTime = rawPerformance.updateDomObjTime; p.applyUpdateTime = rawPerformance.applyUpdateTime; p.cssLayoutTime = rawPerformance.cssLayoutTime; p.totalTime = rawPerformance.totalTime; p.networkTime = rawPerformance.networkTime; p.pureNetworkTime = rawPerformance.pureNetworkTime; p.actualNetworkTime = rawPerformance.actualNetworkTime; p.componentCount = rawPerformance.componentCount; p.JSLibVersion = rawPerformance.JSLibVersion; p.WXSDKVersion = rawPerformance.WXSDKVersion; p.pageName = rawPerformance.pageName; p.templateUrl = rawPerformance.templateUrl; p.requestType = rawPerformance.requestType; p.connectionType = rawPerformance.connectionType; return p; }
Example #13
Source File: WXSDKInstance.java From weex-uikit with MIT License | 5 votes |
public void init(Context context) { mContext = context; mNativeInvokeHelper = new NativeInvokeHelper(mInstanceId); mWXPerformance = new WXPerformance(); mWXPerformance.WXSDKVersion = WXEnvironment.WXSDK_VERSION; mWXPerformance.JSLibInitTime = WXEnvironment.sJSLibInitTime; mUserTrackAdapter=WXSDKManager.getInstance().getIWXUserTrackAdapter(); }
Example #14
Source File: WXEmbed.java From weex-uikit with MIT License | 5 votes |
private WXSDKInstance createInstance() { WXSDKInstance sdkInstance = getInstance().createNestedInstance(this); getInstance().addOnInstanceVisibleListener(this); sdkInstance.registerRenderListener(mListener); String url=src; if(mListener != null && mListener.mEventListener != null){ url=mListener.mEventListener.transformUrl(src); if(!mListener.mEventListener.onPreCreate(this,src)){ //cancel render return null; } } if(TextUtils.isEmpty(url)){ mListener.mEventListener.onException(this,WXRenderErrorCode.WX_USER_INTERCEPT_ERROR,"degradeToH5"); return sdkInstance; } ViewGroup.LayoutParams layoutParams = getHostView().getLayoutParams(); sdkInstance.renderByUrl(WXPerformance.DEFAULT, url, null, null, layoutParams.width, layoutParams.height, WXRenderStrategy.APPEND_ASYNC); return sdkInstance; }
Example #15
Source File: WXSoInstallMgrSdk.java From weex-uikit with MIT License | 5 votes |
static void commit(IWXUserTrackAdapter utAdapter, String errCode, String errMsg) { if (utAdapter == null) { return; } if (errCode != null && errMsg != null) { WXPerformance p = new WXPerformance(); p.errCode = errCode; p.errMsg = errMsg; utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, p, null); } else { utAdapter.commit(null, null, WXEnvironment.ENVIRONMENT, null, null); } }
Example #16
Source File: WXBridgeManager.java From weex-uikit with MIT License | 5 votes |
public void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg) { WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); IWXUserTrackAdapter adapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if (instance == null || adapter == null || errCode == null) { return; } WXPerformance performance = new WXPerformance(); performance.args=instance.getBundleUrl(); performance.errCode=errCode.getErrorCode(); if (errCode != WXErrorCode.WX_SUCCESS) { performance.appendErrMsg(TextUtils.isEmpty(errMsg)?errCode.getErrorMsg():errMsg); WXLogUtils.e("wx_monitor",performance.toString()); } adapter.commit(WXEnvironment.getApplication(), null, IWXUserTrackAdapter.JS_BRIDGE, performance, instance.getUserTrackParams()); }
Example #17
Source File: BenchmarkTest.java From incubator-weex-playground with Apache License 2.0 | 5 votes |
@Repeat(TIMES) @Test public void testFirstFirstScreenPerformance() { WXPerformance performance = fetchPerformance(); long currentTime = performance.screenRenderTime; long layoutTime = performance.cssLayoutTime; firstScreenRenderTime.add(currentTime); firstScreenLayoutTime.add(layoutTime); Log.d(TAG, "FIRST_SCREEN_RENDER_TIME (activity killed) " + currentTime + " ms"); Log.d(TAG, "FIRST_SCREEN_Layout_TIME (activity killed) " + layoutTime + " ms"); }
Example #18
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 5 votes |
/** * UserTrack Log */ public void commitUTStab(final String type, final WXErrorCode errorCode) { if (TextUtils.isEmpty(type) || errorCode == null) { return; } runOnUiThread(new Runnable() { @Override public void run() { // Record exception if a render error happened. if (mStatisticsListener != null && errorCode != WXErrorCode.WX_SUCCESS) { mStatisticsListener.onException(mInstanceId, errorCode.getErrorCode(), errorCode.getErrorMsg()); } WXPerformance performance = new WXPerformance(); performance.errCode = errorCode.getErrorCode(); performance.args = errorCode.getArgs(); if (errorCode != WXErrorCode.WX_SUCCESS) { performance.errMsg = errorCode.getErrorMsg(); if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(performance.toString()); } } if( mUserTrackAdapter!= null) { mUserTrackAdapter.commit(mContext, null, type, performance, getUserTrackParams()); } } }); }
Example #19
Source File: WXEmbed.java From ucar-weex-core with Apache License 2.0 | 5 votes |
private WXSDKInstance createInstance() { WXSDKInstance sdkInstance = getInstance().createNestedInstance(this); getInstance().addOnInstanceVisibleListener(this); sdkInstance.registerRenderListener(mListener); String url=src; if(mListener != null && mListener.mEventListener != null){ url=mListener.mEventListener.transformUrl(src); if(!mListener.mEventListener.onPreCreate(this,src)){ //cancel render return null; } } if(TextUtils.isEmpty(url)){ mListener.mEventListener.onException(this,WXRenderErrorCode.WX_USER_INTERCEPT_ERROR,"degradeToH5"); return sdkInstance; } ViewGroup.LayoutParams layoutParams = getHostView().getLayoutParams(); sdkInstance.renderByUrl(WXPerformance.DEFAULT, url, null, null, layoutParams.width, layoutParams.height, WXRenderStrategy.APPEND_ASYNC); return sdkInstance; }
Example #20
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 5 votes |
public void init(Context context) { mContext = context; mNativeInvokeHelper = new NativeInvokeHelper(mInstanceId); mWXPerformance = new WXPerformance(); mWXPerformance.WXSDKVersion = WXEnvironment.WXSDK_VERSION; mWXPerformance.JSLibInitTime = WXEnvironment.sJSLibInitTime; mUserTrackAdapter=WXSDKManager.getInstance().getIWXUserTrackAdapter(); }
Example #21
Source File: WXSDKInstance.java From weex-uikit with MIT License | 4 votes |
public void onRenderSuccess(final int width, final int height) { firstScreenRenderFinished(); long time = System.currentTimeMillis() - mRenderStartTime; WXLogUtils.renderPerformanceLog("onRenderSuccess", time); WXLogUtils.renderPerformanceLog(" invokeCreateInstance",mWXPerformance.communicateTime); WXLogUtils.renderPerformanceLog(" TotalCallNativeTime", mWXPerformance.callNativeTime); WXLogUtils.renderPerformanceLog(" TotalJsonParseTime", mWXPerformance.parseJsonTime); WXLogUtils.renderPerformanceLog(" TotalBatchTime", mWXPerformance.batchTime); WXLogUtils.renderPerformanceLog(" TotalCssLayoutTime", mWXPerformance.cssLayoutTime); WXLogUtils.renderPerformanceLog(" TotalApplyUpdateTime", mWXPerformance.applyUpdateTime); WXLogUtils.renderPerformanceLog(" TotalUpdateDomObjTime", mWXPerformance.updateDomObjTime); mWXPerformance.totalTime = time; if(mWXPerformance.screenRenderTime<0.001){ mWXPerformance.screenRenderTime = time; } mWXPerformance.componentCount = WXComponent.mComponentNum; if(WXEnvironment.isApkDebugable()) { WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, "mComponentNum:" + WXComponent.mComponentNum); } WXComponent.mComponentNum = 0; if (mRenderListener != null && mContext != null) { runOnUiThread(new Runnable() { @Override public void run() { if (mRenderListener != null && mContext != null) { mRenderListener.onRenderSuccess(WXSDKInstance.this, width, height); if (mUserTrackAdapter != null) { WXPerformance performance=new WXPerformance(); performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode(); performance.args=getBundleUrl(); mUserTrackAdapter.commit(mContext,null,IWXUserTrackAdapter.JS_BRIDGE,performance,getUserTrackParams()); } if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString()); } } } }); } if(!WXEnvironment.isApkDebugable()){ Log.e("weex_perf",mWXPerformance.getPerfData()); } }
Example #22
Source File: BenchmarkTest.java From incubator-weex-playground with Apache License 2.0 | 4 votes |
private WXPerformance fetchPerformance() { return loadWeexPage().getWXInstance().getWXPerformance(); }
Example #23
Source File: WXSDKInstanceTest.java From weex-uikit with MIT License | 4 votes |
@Test public void testRenderByUrl() throws Exception { mInstance.renderByUrl(WXPerformance.DEFAULT,"file:///test",null,null,100,100, WXRenderStrategy.APPEND_ASYNC); mInstance.renderByUrl(WXPerformance.DEFAULT,"http://taobao.com",null,null,100,100, WXRenderStrategy.APPEND_ASYNC); }
Example #24
Source File: WXSDKInstance.java From weex-uikit with MIT License | 4 votes |
@Override public void onHttpFinish(WXResponse response) { mWXPerformance.networkTime = System.currentTimeMillis() - startRequestTime; if(response.extendParams!=null){ Object actualNetworkTime=response.extendParams.get("actualNetworkTime"); mWXPerformance.actualNetworkTime=actualNetworkTime instanceof Long?(long)actualNetworkTime:0; WXLogUtils.renderPerformanceLog("actualNetworkTime", mWXPerformance.actualNetworkTime); Object pureNetworkTime=response.extendParams.get("pureNetworkTime"); mWXPerformance.pureNetworkTime=pureNetworkTime instanceof Long?(long)pureNetworkTime:0; WXLogUtils.renderPerformanceLog("pureNetworkTime", mWXPerformance.pureNetworkTime); Object connectionType=response.extendParams.get("connectionType"); mWXPerformance.connectionType=connectionType instanceof String?(String)connectionType:""; Object packageSpendTime=response.extendParams.get("packageSpendTime"); mWXPerformance.packageSpendTime=packageSpendTime instanceof Long ?(long)packageSpendTime:0; Object syncTaskTime=response.extendParams.get("syncTaskTime"); mWXPerformance.syncTaskTime=syncTaskTime instanceof Long ?(long)syncTaskTime:0; Object requestType=response.extendParams.get("requestType"); mWXPerformance.requestType=requestType instanceof String?(String)requestType:""; if("network".equals(requestType) && mUserTrackAdapter!=null){ WXPerformance performance=new WXPerformance(); if(!TextUtils.isEmpty(mBundleUrl)){ try { performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString(); } catch (Exception e) { performance.args=pageName; } } if(!"200".equals(response.statusCode)){ performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode(); performance.appendErrMsg(response.errorCode); performance.appendErrMsg("|"); performance.appendErrMsg(response.errorMsg); }else if("200".equals(response.statusCode) && (response.originalData==null || response.originalData.length<=0)){ performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode(); performance.appendErrMsg(response.statusCode); performance.appendErrMsg("|template is null!"); }else { performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode(); } mUserTrackAdapter.commit(getContext(),null,IWXUserTrackAdapter.JS_DOWNLOAD,performance,null); } } WXLogUtils.renderPerformanceLog("networkTime", mWXPerformance.networkTime); if (response!=null && response.originalData!=null && TextUtils.equals("200", response.statusCode)) { String template = new String(response.originalData); render(pageName, template, options, jsonInitData, flag); } else if (TextUtils.equals(WXRenderErrorCode.WX_USER_INTERCEPT_ERROR, response.statusCode)) { WXLogUtils.d("user intercept"); onRenderError(WXRenderErrorCode.WX_USER_INTERCEPT_ERROR,response.errorMsg); } else { onRenderError(WXRenderErrorCode.WX_NETWORK_ERROR, response.errorMsg); } }
Example #25
Source File: WXSDKInstance.java From weex-uikit with MIT License | 4 votes |
public WXPerformance getWXPerformance(){ return mWXPerformance; }
Example #26
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public WXPerformance getWXPerformance(){ return mWXPerformance; }
Example #27
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 4 votes |
public void onRenderSuccess(final int width, final int height) { firstScreenRenderFinished(); long time = System.currentTimeMillis() - mRenderStartTime; WXLogUtils.renderPerformanceLog("onRenderSuccess", time); WXLogUtils.renderPerformanceLog(" invokeCreateInstance",mWXPerformance.communicateTime); WXLogUtils.renderPerformanceLog(" TotalCallNativeTime", mWXPerformance.callNativeTime); WXLogUtils.renderPerformanceLog(" TotalJsonParseTime", mWXPerformance.parseJsonTime); WXLogUtils.renderPerformanceLog(" TotalBatchTime", mWXPerformance.batchTime); WXLogUtils.renderPerformanceLog(" TotalCssLayoutTime", mWXPerformance.cssLayoutTime); WXLogUtils.renderPerformanceLog(" TotalApplyUpdateTime", mWXPerformance.applyUpdateTime); WXLogUtils.renderPerformanceLog(" TotalUpdateDomObjTime", mWXPerformance.updateDomObjTime); mWXPerformance.totalTime = time; if(mWXPerformance.screenRenderTime<0.001){ mWXPerformance.screenRenderTime = time; } mWXPerformance.componentCount = WXComponent.mComponentNum; if(WXEnvironment.isApkDebugable()) { WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, "mComponentNum:" + WXComponent.mComponentNum); } WXComponent.mComponentNum = 0; if (mRenderListener != null && mContext != null) { runOnUiThread(new Runnable() { @Override public void run() { if (mRenderListener != null && mContext != null) { mRenderListener.onRenderSuccess(WXSDKInstance.this, width, height); if (mUserTrackAdapter != null) { WXPerformance performance=new WXPerformance(); performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode(); performance.args=getBundleUrl(); mUserTrackAdapter.commit(mContext,null,IWXUserTrackAdapter.JS_BRIDGE,performance,getUserTrackParams()); } if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString()); } } } }); } if(!WXEnvironment.isApkDebugable()){ Log.e("weex_perf",mWXPerformance.getPerfData()); } }
Example #28
Source File: WXSDKInstanceTest.java From ucar-weex-core with Apache License 2.0 | 4 votes |
@Test public void testRenderByUrl() throws Exception { mInstance.renderByUrl(WXPerformance.DEFAULT,"file:///test",null,null,100,100, WXRenderStrategy.APPEND_ASYNC); mInstance.renderByUrl(WXPerformance.DEFAULT,"http://taobao.com",null,null,100,100, WXRenderStrategy.APPEND_ASYNC); }
Example #29
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 4 votes |
@Override public void onHttpFinish(WXResponse response) { if (this.instance != null && this.instance.getWXStatisticsListener() != null) { this.instance.getWXStatisticsListener().onHttpFinish(); } mWXPerformance.networkTime = System.currentTimeMillis() - startRequestTime; if(response.extendParams!=null){ Object actualNetworkTime=response.extendParams.get("actualNetworkTime"); mWXPerformance.actualNetworkTime=actualNetworkTime instanceof Long?(long)actualNetworkTime:0; WXLogUtils.renderPerformanceLog("actualNetworkTime", mWXPerformance.actualNetworkTime); Object pureNetworkTime=response.extendParams.get("pureNetworkTime"); mWXPerformance.pureNetworkTime=pureNetworkTime instanceof Long?(long)pureNetworkTime:0; WXLogUtils.renderPerformanceLog("pureNetworkTime", mWXPerformance.pureNetworkTime); Object connectionType=response.extendParams.get("connectionType"); mWXPerformance.connectionType=connectionType instanceof String?(String)connectionType:""; Object packageSpendTime=response.extendParams.get("packageSpendTime"); mWXPerformance.packageSpendTime=packageSpendTime instanceof Long ?(long)packageSpendTime:0; Object syncTaskTime=response.extendParams.get("syncTaskTime"); mWXPerformance.syncTaskTime=syncTaskTime instanceof Long ?(long)syncTaskTime:0; Object requestType=response.extendParams.get("requestType"); mWXPerformance.requestType=requestType instanceof String?(String)requestType:""; if("network".equals(requestType) && mUserTrackAdapter!=null){ WXPerformance performance=new WXPerformance(); if(!TextUtils.isEmpty(mBundleUrl)){ try { performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString(); } catch (Exception e) { performance.args=pageName; } } if(!"200".equals(response.statusCode)){ performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode(); performance.appendErrMsg(response.errorCode); performance.appendErrMsg("|"); performance.appendErrMsg(response.errorMsg); }else if("200".equals(response.statusCode) && (response.originalData==null || response.originalData.length<=0)){ performance.errCode=WXErrorCode.WX_ERR_JSBUNDLE_DOWNLOAD.getErrorCode(); performance.appendErrMsg(response.statusCode); performance.appendErrMsg("|template is null!"); }else { performance.errCode=WXErrorCode.WX_SUCCESS.getErrorCode(); } if (mUserTrackAdapter != null) { mUserTrackAdapter.commit(getContext(), null, IWXUserTrackAdapter.JS_DOWNLOAD, performance, null); } } } WXLogUtils.renderPerformanceLog("networkTime", mWXPerformance.networkTime); if (response!=null && response.originalData!=null && TextUtils.equals("200", response.statusCode)) { String template = new String(response.originalData); render(pageName, template, options, jsonInitData, flag); } else if (TextUtils.equals(WXRenderErrorCode.WX_USER_INTERCEPT_ERROR, response.statusCode)) { WXLogUtils.d("user intercept"); onRenderError(WXRenderErrorCode.WX_USER_INTERCEPT_ERROR,response.errorMsg); } else { onRenderError(WXRenderErrorCode.WX_NETWORK_ERROR, response.errorMsg); } }
Example #30
Source File: WXSDKInstance.java From ucar-weex-core with Apache License 2.0 | 3 votes |
/** * Render template asynchronously * * @param pageName, used for performance log. * @param template bundle js * @param options os iphone/android/ipad * weexversion Weex version(like 1.0.0) * appversion App version(like 1.0.0) * devid Device id(like Aqh9z8dRJNBhmS9drLG5BKCmXhecHUXIZoXOctKwFebH) * sysversion Device system version(like 5.4.4、7.0.4, should be used with os) * sysmodel Device model(like iOS:"MGA82J/A", android:"MI NOTE LTE") * Time UNIX timestamp, UTC+08:00 * TTID(Optional) * MarkertId * Appname(Optional) tm,tb,qa * Bundleurl(Optional) template url * @param jsonInitData Initial data for rendering * @param flag RenderStrategy {@link WXRenderStrategy} */ public void render(String pageName, String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag) { if(WXEnvironment.isApkDebugable() && WXPerformance.DEFAULT.equals(pageName)){ WXLogUtils.e("Please set your pageName or your js bundle url !!!!!!!"); return; } renderInternal(pageName,template,options,jsonInitData,flag); }