You are measuring time which is required to initialize 10000 button objects without drawing them on a screen. To calculate exact amount of time from starting application to moment when users see all buttons on a screen, you need to use event listener attached to window object.
Try something like to this:
function renderButtons() {
var win = Ti.UI.createWindow({
backgroundColor: 'B8B8B8',
exitOnClose: true,
fullscreen: 'false',
title: 'Label Demo'
});
var start = new Date().getTime();
for (var count = 0; count < 1000; count++) {
win.add( createRandomButton() );
}
alert('init: ' + (new Date().getTime() - start));
win.addEventListener('postlayout', function(){
alert('postlayout: ' + (new Date().getTime() - start));
});
win.open();
}
If you need to close window immediately after rendering is done add win.close()
in eventListener to prevent calling it in the middle of drawing it on a screen:
win.addEventListener('postlayout', function(){
alert('postlayout: ' + (new Date().getTime() - start));
win.close();
});