Skip to content

Instantly share code, notes, and snippets.

@freddymontano
Created July 5, 2012 19:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freddymontano/3056032 to your computer and use it in GitHub Desktop.
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)
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');
@TiVince
Copy link

TiVince commented Sep 18, 2012

have you tried
data[i] = createRow(...) in the loop instead of data.push ? for me it was faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment