0
我目前正在使用第三方指令,並且我想花時間在屏幕上呈現某些內容。定時需要多長時間呈現角度
console.time('time');
tableservice.setColumns(columns);
var dataView = new DataView();
dataView.setItems(datarows);
$scope.columns = tableservice.getColumns();
$scope.dataView = dataView;
console.timeEnd('time');
這是我爲提供模型而生成的代碼,以便它可以顯示在視圖上。
我想花時間多久,並看到console.time方法變化太多,時間是可怕的。
有時我會得到0.000ms和1.000ms,這根本就不是很好。
對我來說,測試一下在視圖上渲染某些東西需要多長時間的最佳方式是什麼?
編輯:
我已經嘗試了很多的方法,時間,他們似乎都跳來跳去太多,所以我假定時間不是很準確。
有沒有更好的方法來測試模型渲染到屏幕上需要多長時間?
你可以看看到[Batarang(https://chrome.google.com/webstore/detail/angularjs-batarang/ighdmehidhipcmcojjgiloacoafjmpfk ?hl = en)too :) – 2014-09-24 22:24:23
渲染髮生在你離開「Angular execution context」之後,請參閱https://docs.angularjs.org/guide/scope#integration-with-the-browser-event-loop因此,我認爲你只是測量JavaScript代碼的執行情況,而不是渲染。 – 2014-09-25 00:26:45
我不知道你嘗試了哪種計時方法,但是你試過[用戶計時API](http://www.w3.org/TR/user-timing/)(使用'mark(...)'和'measure(...)'?[尚未完全支持](http://caniuse.com/#feat=user-timing),但我會試一試...... – 2014-09-25 00:34:35