8 Replies Latest reply on Jun 9, 2011 12:01 AM by chris.campbell

    Major javascript performance issue found!

    NotifyWire
      Already sent this into the feeback page, but wanted to post this here for everyone else to note/comment on.

       

      Creating instances of an object that has a function as a public member causes object creation time to slow WAY down as the number of objects increase.  The same test without a public function is always fast.

       

       

      The test loops in batches of 20 creating 1000 objects at a time.  When you run it in an Adobe Air app, the objects w/function batches get slower (some times taking as long as 4 seconds!), then erratic.  The objects wo/function batches are always fast.

       

      I'm running this on Win7 x64 with Adobe Air 2.6.  I tried it going back to Air 2.0 and had the same problem.  This same test runs fine in IE9, Chrome, Safari 5, Appcelerator Titanium, but none have this problem.

       

      Here's the test, just plug it into the document.ready/load of any app...please someone tell me I'm crazy...

       

       

      var objectsWithFunctions = [];
      var objectsWithoutFunctions = [];
      var t1 = null;
      for (var b = 0; b < 20; b++) { // b is for batch
      t1 = new Date().getTime();
      for (var i = 0; i < 1000; i++) {
      objectsWithFunctions.push({
      prop1: "some string",
      prop2: function(){
      return "another string";
      }
      });
      };
      alert("Time to make batch " + b + " of objects with functions - " + (new Date().getTime() - t1));
      }
      alert("Ok, going to make objects without functions now...");
      for (var b = 0; b < 20; b++) {
      t1 = new Date().getTime();
      for (var i = 0; i < 1000; i++) {
      objectsWithoutFunctions.push({
      prop1: "some string",
      prop2: "another string"
      });
      };
      alert("Time to make batch " + b + " of objects without functions - " + (new Date().getTime() - t1));
      }