flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Mclean (JIRA)" <j...@apache.org>
Subject [jira] [Created] (FLEX-35330) [FlexJS] comparison of objects using non strict inequality is slow
Date Sat, 24 Jun 2017 02:43:01 GMT
Justin Mclean created FLEX-35330:
------------------------------------

             Summary: [FlexJS] comparison of objects using non strict inequality is slow
                 Key: FLEX-35330
                 URL: https://issues.apache.org/jira/browse/FLEX-35330
             Project: Apache Flex
          Issue Type: Bug
    Affects Versions: Apache FlexJS 0.7.0
            Reporter: Justin Mclean


Code use to test:

{code}
<?xml version="1.0" encoding="utf-8"?>
<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                xmlns:js="library://ns.apache.org/flexjs/basic" applicationComplete="init()">

    <js:valuesImpl>
        <js:SimpleCSSValuesImpl/>
    </js:valuesImpl>

    <fx:Script><![CDATA[
            protected function init():void
            {
                var start:Date;
                var end:Date;
                var took:Number;
                var obj1:Object;
                var obj2:Object;
                var obj3:Object = null;
                var obj4:Object = null;
                var i:int;
                var j:int;

                j = 0;
                start = new Date();
                for (i = 0; i < 1e7; i++) {
                    if (obj1 != null) {
                        j++;
                    }
                }
                end = new Date();
                took = end.getTime() - start.getTime();
                trace("Uninitialised != : " + took);

                j = 0;
                start = new Date();
                for (i = 0; i < 1e7; i++) {
                    if (obj2 !== null) {
                        j++;
                    }
                }
                end = new Date();
                took = end.getTime() - start.getTime();
                trace("Uninitialised !== : " + took);

                j = 0;
                start = new Date();
                for (i = 0; i < 1e7; i++) {
                    if (obj3 != null) {
                        j++;
                    }
                }
                end = new Date();
                took = end.getTime() - start.getTime();
                trace("Null initialised != : " + took);

                j = 0;
                start = new Date();
                for (i = 0; i < 1e7; i++) {
                    if (obj4 !== null) {
                        j++;
                    }
                }
                end = new Date();
                took = end.getTime() - start.getTime();
                trace("Null initialised !== : " + took);
            }
        ]]></fx:Script>

    <js:initialView>
        <js:View percentWidth="100" percentHeight="100">
            <js:Label id="result" />
        </js:View>
    </js:initialView>

</js:Application>

{code}

Output of 5 consecutive tests:

Uninitialised != : 18
Language.js:354 Uninitialised !== : 18
Language.js:354 Null initialised != : 16
Language.js:354 Null initialised !== : 13

Uninitialised != : 20
Language.js:354 Uninitialised !== : 18
Language.js:354 Null initialised != : 17
Language.js:354 Null initialised !== : 14

Uninitialised != : 18
Language.js:354 Uninitialised !== : 19
Language.js:354 Null initialised != : 16
Language.js:354 Null initialised !== : 14

Uninitialised != : 18
Language.js:354 Uninitialised !== : 18
Language.js:354 Null initialised != : 16
Language.js:354 Null initialised !== : 14

Uninitialised != : 19
Language.js:354 Uninitialised !== : 18
Language.js:354 Null initialised != : 17
Language.js:354 Null initialised !== : 14

Smaller numbers are faster. Run on Chrome 55 on OSX.

You can see about a 35% performance increase.

Note there is also a small performance increase in use non strict inequality and assigning
to null.





--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message