Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-13165

Ti.UI.createView({}) takes significantly longer than Ti.UI.createView()

    Details

      Description

      Measure Ti.UI.createView(). Measure Ti.UI.createView({}). Note that the latter takes over twice if not three times the time than the former.

      Find other expenses due to ddms analysis.

      Expenses turn out due to style sheet handling, even when there is no style sheet, and in string building, especially debug statements that require expensive string building without anything logged.

      // this sets the background color of the master UIView (when there are no windows/tab groups on it)
      Titanium.UI.setBackgroundColor('#000');
       
      // create base UI tab and root window
      var win = Titanium.UI.createWindow({  
          title:'Tab 1',
          backgroundColor:'#fff'
      });
       
      var label1 = Titanium.UI.createLabel({
      	color:'#999',
      	text:'I am Window 1',
      	font:{fontSize:20,fontFamily:'Helvetica Neue'},
      	textAlign:'center',
      	width:'100%',
      	height:400,
      	top:0
      });
       
      win.add(label1);
       
      function measureFunction(workFunct,name,loopCount,sampleSize){
      	if(!loopCount) loopCount = 500;
      	if(!sampleSize) sampleSize = 20;
      	if(!name) name = "test";
      	var results = [];
      	var sum = 0;
      	var i,j;
       
      	for(j=0;j<sampleSize;j++){
      		label1.text = 'Testing '+Ti.version+' ('+Ti.buildDate+') with '+name+' (' + 100 * j / sampleSize + '%)...';
      		var startTime = Date.now();
      		for(i=0;i<loopCount;i++){
      			workFunct();
      		}
      		var endTime = Date.now();
      		results[j]=endTime-startTime;
      		sum += results[j];
      	}
      	label1.text = 'Results for ' + name + ' (Avg ' + (sum/sampleSize) + '): ' + results.join(', ');
      	Ti.API.debug(label1.text);	
      }
       
      var btn1 = Ti.UI.createButton({width:200,height:60,left:10,top:410,title:'()'});
      btn1.addEventListener('click',function(){
      	measureFunction(function(){Ti.UI.createView();},'no object');
      })
      win.add(btn1);
       
      var btn2 = Ti.UI.createButton({width:200,height:60,left:10,top:490,title:'({})'});
      btn2.addEventListener('click',function(){
      	measureFunction(function(){Ti.UI.createView({});},'empty object');
      })
      win.add(btn2);
       
      var btn3 = Ti.UI.createButton({width:200,height:60,left:10,top:570,title:'({top:5})'});
      btn3.addEventListener('click',function(){
      	measureFunction(function(){Ti.UI.createView({top:5});},'simple object');
      })
      win.add(btn3);
       
       
      win.open();
      
      

        Attachments

          Activity

            People

            • Assignee:
              ingo Ingo Muschenetz
              Reporter:
              ingo Ingo Muschenetz
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-15975
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration