Why is execution time for recursive promise so high on Edge? On chrome it is almost instantaneous for 100000 records


  • In my code (see original SO question the promise is recursively called after completion of itself. I ran the following code snippet on Edge and on Chrome and am seeing a marked difference in execution time.

    Please ignore the promise 'anti-pattern'. It is just to simulate an asynchronous method.

    Chrome result - Count - 99999 Start 1512416096194 last update 1512416096509 End 1512416096577 recursiveFnReturnsPromise finished

    execution time - 397ms

    Edge result - Count - 99999 Start 1512415183349 last update 1512415508413 End 1512415907219 recursiveFnReturnsPromise finished

    execution time between the start and the end- 723870ms

    execution time between last the DOM update and the end- 398806ms

    //large array
    let aValues = Array(100000);
    //utility function
    function writeln(text) {
      let p = document.createElement('div');
      p.innerText = text;
    writeln('Start '; //note start recursion time
    recursiveFnReturnsPromiseV1(aValues, 1).then(function() {
      writeln('End ';//note end recursion time
      writeln('recursiveFnReturnsPromise finished');
    }, function() {
      writeln('recursiveFnReturnsPromise failed');
    //the recursive functions which returns a promise
    function recursiveFnReturnsPromiseV1(pValues, ix) {
      if (pValues.length <= ix)
        return Promise.resolve();
      return new Promise(function(c, e) {
        document.getElementById('output').innerText = ix;
        if(ix==99999) writeln('last update ';
      }).then(function() {
        return recursiveFnReturnsPromiseV1(pValues, ++ix);

    Monday, December 04, 2017 11:29 PM

All replies