I have tried the tool with node-dom (https://github.com/Ayms/node-dom) to check what it would give on a whole site, not only a framework, see the result below for a usual web site (here http://www.castorama.fr), I did not compile it yet because it seems that there is a slight problem with the tool :

(function() {}) or (function(){var a=2}) etc ...

returns a BTF candidate...

I discovered it checking http://www.castorama.fr/homepage/homepage_20120227_full_anim.js which returns 21 BTF (because I was surprised by the result, since these sites are using frameworks we should not expect a lot of BTF functions outside)

As far as I have understood "Total Function Expressions" is supposed to return all functions that do not contain "this" in their initial scope and that have a "var self=this" trick that is used somewhere inside the function (ie function() {var self=this;var b=function() {console.log('test')} is not a BTF candidate because self is not used), correct ?


---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script http://www.castorama.fr/store/js/jquery.js
Total Function Expressions*:417 52.85% of 789
Expression Functions**:132 31.65%
Expression Functions That Return an Object Literal:2 0.48%
Functions with a single statement: 95 22.78%
Block Functions:190 45.56%
---------- script http://www.castorama.fr/store/js/main.js
Total Function Expressions*:49 72.06% of 68
Expression Functions**:1 2.04%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 26 53.06%
Block Functions:22 44.90%
---------- script inline
Total Function Expressions*:4 100.00% of 4
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 3 75.00%
Block Functions:1 25.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script http://www.castorama.fr/store/js/jquery.js
Total Function Expressions*:417 52.85% of 789
Expression Functions**:132 31.65%
Expression Functions That Return an Object Literal:2 0.48%
Functions with a single statement: 95 22.78%
Block Functions:190 45.56%
---------- script http://www.castorama.fr/homepage/homepage_20120227_full_anim.js
Total Function Expressions*:21 100.00% of 21
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 17 80.95%
Block Functions:4 19.05%
---------- script http://www.castorama.fr/homepage/homepage_20120227_full_menu.js
Total Function Expressions*:1 50.00% of 2
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 1 100.00%
Block Functions:0 0.00%
---------- script http://www.castorama.fr/js/jquery.cookie.js
Total Function Expressions*:1 100.00% of 1
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 1 100.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script http://www.castorama.fr/js/s_code.js
Total Function Expressions*:6 60.00% of 10
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 2 33.33%
Block Functions:4 66.67%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script http://www.castorama.fr/js/tc_Castoramafr_1_load.js
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script http://www.castorama.fr/js/tc_Castoramafr_1_exec.js
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script https://ssl.google-analytics.com/urchin.js
Total Function Expressions*:6 100.00% of 6
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 6 100.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
Document complete
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%
---------- script inline
Total Function Expressions*:0 0.00% of 0
Expression Functions**:0 0.00%
Expression Functions That Return an Object Literal:0 0.00%
Functions with a single statement: 0 0.00%
Block Functions:0 0.00%

Le 14/03/2012 05:03, Kevin Smith a écrit :
Hi Allen,

I've updated the tool to count the number of potential object literal methods as well. I'll post details tomorrow.

kevin

On Tue, Mar 13, 2012 at 11:12 PM, Allen Wirfs-Brock <[email protected] <mailto:[email protected]>> wrote:

    Function expressions in object literals that could use concise
    method syntax?



    Rick Waldron <[email protected]
    <mailto:[email protected]>> wrote:

    Kevin,

    Over the weekend I applied David Herman's new tri-lambda syntax to
    Popcorn.js to see how it would look and feel:

    https://github.com/rwldrn/popcorn-js/compare/tri-lambda

    So, just now I ran Popcorn.js through your Analytics Machine, here
    is the output:

    Total Function Expressions*:        63      65.625%
    Expression Functions**:     12      19.047619047619047%
    Expression Functions That Return an Object Literal:         0       0%
    Functions with a single statement:  9       14.285714285714285%
    Block Functions:    42      66.66666666666666%

    * Does not include function expressions that contain references to
    'this' in its immediate scope.

    ** Function expressions whose first statement is a return.


          Parameter List Length

    0   17.46031746031746%
    1   47.61904761904761%
    2   30.158730158730158%
    3   4.761904761904762%
    4 or more   0%


    On Tue, Mar 13, 2012 at 8:55 PM, Kevin Smith <[email protected]
    <mailto:[email protected]>> wrote:

        I've updated the tool to also analyze the number of formal
        parameters for each BTF candidate.  I've haven't had time to
        update the spreadsheet, but for every body of code that I've
        sampled so far, 1 is the most common number of formal parameters.

        This suggests that optimizing syntax for BTFs with one
        parameter might be worthwhile.

        kevin

        _______________________________________________
        es-discuss mailing list
        [email protected] <mailto:[email protected]>
        https://mail.mozilla.org/listinfo/es-discuss





_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

--

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to