[Webkit-unassigned] [Bug 237385] let vs var performance

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Mar 3 06:37:07 PST 2022


https://bugs.webkit.org/show_bug.cgi?id=237385

jeremy.tellaa at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---

--- Comment #4 from jeremy.tellaa at gmail.com ---
I am reoping this. I think some optimisation is not made in one cases. I made two benches:

<script type="text/javascript">
  const f = () => { for (let i = 0; i < nb; i++) { } };

  const nb = 1000 * 1000 * 1000;
  const t0 = performance.now();
  f();
  const t1 = performance.now();
  const res = Math.floor(t1 - t0);

  const txt = `Looping ${nb} times with took ${res}ms.`
  document.getElementById('root').innerHTML = txt;
</script>

<script type="text/javascript">
  const f = () => { for (var i = 0; i < nb; i++) { } };

  const nb = 1000 * 1000 * 1000;
  const t0 = performance.now();
  f();
  const t1 = performance.now();
  const res = Math.floor(t1 - t0);

  const txt = `Looping ${nb} times with took ${res}ms.`
  document.getElementById('root').innerHTML = txt;
</script>

I ran those separately a bunch of times after clicking on "Empty the caches" every time between runs. This first one takes ~10 seconds while the second one ~3 seconds.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220303/3e8259df/attachment.htm>


More information about the webkit-unassigned mailing list