Hybrid View

  1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,311
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default Ext.draw - Ext.create usage dropped - why?

    Ext.draw - Ext.create usage dropped - why?


    I see that in many classes in the Ext.draw package the Ext.create pattern was replaced by new Ext.draw...().

    Why? Is using Ext.create() too slow?

    Here's an example from the Ext.draw.Surface class:

    4.0.7
    Code:
        initItems: function() {
            var items = this.items;
            this.items = Ext.create('Ext.draw.CompositeSprite');
            this.groups = Ext.create('Ext.draw.CompositeSprite');
            if (items) {
                this.add(items);
            }
        }
    4.1 Beta
    Code:
        initItems: function() {
            var items = this.items;
            this.items = new Ext.draw.CompositeSprite();
            this.groups = new Ext.draw.CompositeSprite();
            if (items) {
                this.add(items);
            }
        }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    We have been removing Ext.create internally as using Ext.create is slower than using new.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,339
    Vote Rating
    132
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    You are correct: 'Ext.create' is slower than 'new'. Its chief benefit is for situations where the class name is a dynamic value and 'new' is not an option. As long as the 'requires' declarations are correct, the overhead of 'Ext.create' is simply not needed.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  4. #4
    Ext JS Premium Member Sébastien.Volle's Avatar
    Join Date
    Apr 2011
    Location
    Grenoble, France
    Posts
    70
    Vote Rating
    0
    Sébastien.Volle is on a distinguished road

      0  

    Default


    Ah. Well, I was under the impression that using Ext.create was best practice according to the documentation and tutorials.
    aka Seboss

  5. #5
    Sencha User
    Join Date
    Mar 2011
    Location
    Germany
    Posts
    198
    Vote Rating
    1
    Nickname is on a distinguished road

      0  

    Default


    Hi,

    is there any number how much slower Ext.create() is?
    Looked at the ClassManager file and it normally should just lookup the class definition in an object and then with the "Instantiator" wrapper instantiate the new instance.

    Edit:
    Ok, I just ran my own tests and it seems like micro optimizations (unless you really instantiate more than 100000 classes)

    PHP Code:

    Ext
    .define('MyClass', {
        
    constructor: function() {
            
    this.callParent();
        }
    });

    var 
    = new Date().getTime(),
        
    0,
        
    len 500000,
        
    ml;

    for(; 
    leni++) {
        
    ml Ext.create('MyClass');
        
    ml null;
    }

    console.log('Run with Ext.create() took ' + (new Date().getTime() - s)+ 'ms');


    = new Date().getTime();
    0;

    for(; 
    leni++) {
        
    ml = new MyClass();
        
    ml null;
    }

    console.log('Run with native "new" took ' + (new Date().getTime() - s)+ 'ms'); 
    Chrome 14:
    Run with Ext.create() took 1625ms

    Run with native "new" took 1268ms

    FireFox9:
    Run with Ext.create() took 5796ms

    Run with native "new" took 3968ms
    on a i5 620, 6RAM, ubuntu 10.10

    Edit2:
    Numbers above are with 4.1 beta1

    Numbers with 4.0.7:

    Chrome14:
    Run with Ext.create() took 1376ms
    Run with native "new" took 1009ms


    FireFox9:
    Run with Ext.create() took 5800ms
    Run with native "new" took 3965ms

    same system

  6. #6
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,339
    Vote Rating
    132
    dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all dongryphon is a name known to all

      0  

    Default


    Quote Originally Posted by Nickname View Post
    is there any number how much slower Ext.create() is?
    Edit:
    Ok, I just ran my own tests and it seems like micro optimizations (unless you really instantiate more than 100000 classes)
    Good info, thanks!

    I notice you didn't test IE6, 7 and 8 though ... on those browsers, this is not such a micro optimization.

    While we don't instantiate 10k items this way, we do instantiate hundreds or maybe 1k or so, depending on complexity of the UI. Easy trimmings and also makes debugging much simpler since one can easily step in to the constructor using 'new'.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  7. #7
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,311
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    The switch from Ext.create to new is inconsistently applied. For example, the VML engine still uses Ext.create. I have an application where 400 to 600 sprites are created. Since I need to support IE7, I'd see some performance improvement if new was used.

    Code:
    Ext.define('Ext.draw.engine.Vml', {
        ...
        createItem: function (config) {
            return Ext.create('Ext.draw.Sprite', config);
        },
        ...

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi