Created
July 5, 2012 19:51
-
-
Save freddymontano/3056032 to your computer and use it in GitHub Desktop.
Testing TableView performance using a variable (function) instead of calling Ti.UI.createTableViewRow inside the loop. (see https://gist.github.com/2989311)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({ | |
backgroundColor: '#ccc' | |
}); | |
win.open(); | |
var table = Ti.UI.createTableView(); | |
win.add(table); | |
var SELECTION_STYLE_BLUE = Ti.UI.iPhone.TableViewCellSelectionStyle.BLUE; | |
var createRow = Ti.UI.createTableViewRow; | |
// Start the timer | |
var time = new Date().getTime(); | |
// ========================================== | |
var data = []; | |
for(var i = 0; i < 10000; i++){ | |
data.push( | |
createRow({ | |
title:'Row #'+i, | |
selectionStyle: SELECTION_STYLE_BLUE | |
}) | |
); | |
} | |
table.setData(data); | |
// ========================================== | |
// End the timer | |
var end = new Date().getTime(); | |
alert('It took ' + (end - time)+'ms'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have you tried
data[i] = createRow(...) in the loop instead of data.push ? for me it was faster.