Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-6250 in a recent build.
  1. #1
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,394
    Vote Rating
    175
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default Delegate Ext.Object.chain to Object.create

    Delegate Ext.Object.chain to Object.create


    This is a performance improvement suggestion.

    Ext.Object.chain could be delegated (on supported platforms) to Object.create. This would improve performance.

    Object.create
    Ext.Object.chain

    Try this test. You will see that Object.create is at least 50% faster.

    EDIT
    Also, see this similar delegation Ext.Object.getKeys --> Object.keys


    Code:
    var obj = {
        key1: 'xxx',
        key2: 'yyy',
        key3: 'zzz',
        key4: 'www',
        key5: 'aaa'    
    }
    
    console.time('chain');
    for (var i=0; i<10000; i++) {
        Ext.Object.chain(obj);
    }
    console.timeEnd('chain');
    
    console.time('create');
    for (var i=0; i<10000; i++) {
        Object.create(obj);
    }
    console.timeEnd('create');
    *** EDIT 5/18/12
    See how the Compose library checks if Object.create is available.
    Last edited by LesJ; 18 May 2012 at 5:49 AM. Reason: Add Compose link

  2. #2
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,394
    Vote Rating
    175
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default


    Hello, I hope we are paying attention to performance improvement suggestions in this forum.

    This simple and effective change will speed up object composition in Ext JS. This will make a difference in an application where you have thousands of objects (e.g. drawing applications).

  3. #3
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,403
    Vote Rating
    147
    dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold

      0  

    Default


    Definitely listening. The gains will be proportional to the number of calls to Ext.Object.chain which is few since we don't use it many cases. The change is still a good suggestion though and makes perfect sense.

    You could hook Ext.Object.chain and count the calls to see if I am correct on that
    Don Griffin
    Engineering Manager - Frameworks (Ext JS / Sencha Touch)

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

    "Use the source, Luke!"

  4. #4
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,394
    Vote Rating
    175
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default


    Quote Originally Posted by dongryphon View Post
    You could hook Ext.Object.chain and count the calls to see if I am correct on that
    The count is 968 times when my application starts. I'm not sure if this number is small or not so small, but thank you for listening

    EDIT
    847 - when this page loads
    http://localhost/wag/js/extjs-4.1.0/examples/index.html

  5. #5
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,394
    Vote Rating
    175
    LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold LesJ is a splendid one to behold

      0  

    Default


    Here is my lightly tested solution. I just added the if statement that delegates to Object.create. I think this is all we need to do.

    Code:
    Ext.Object.chain = function(object) {
        if (Object.create) {
            return Object.create(object);
        }
        TemplateClass.prototype = object;
        var result = new TemplateClass();
        TemplateClass.prototype = null;
        return result;
    }
    
    // Test
    Ext.Object.chain({key: 'value'});

  6. #6
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Location
    Kansas
    Posts
    1,403
    Vote Rating
    147
    dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold

      0  

    Default


    How about?

    Code:
        Ext.Object.chain = Object.create || function (object) {
             TemplateClass.prototype = object;
            var result = new TemplateClass();
            TemplateClass.prototype = null;
            return result;
        }
    Don Griffin
    Engineering Manager - Frameworks (Ext JS / Sencha Touch)

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

    "Use the source, Luke!"

Thread Participants: 1