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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 2 17:21:49 PST 2022


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

Yusuke Suzuki <ysuzuki at apple.com> changed:

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

--- Comment #3 from Yusuke Suzuki <ysuzuki at apple.com> ---
Measuring these very small difference needs very careful crafting of microbenchmarks.

1. The first one is getting a penalty because we inline both and second one gets faster JIT from the beginning.
2. Isolating them into a function is not enough. If we would like to measure this level of small difference, we need to ensure that they are not inlined etc.

Here is the changed benchmark. It is executed via JSC shell since inlining control is available to JSC shell.

```
function varTest(nb) {
  for (var i = 0; i < nb; i++) { };
}
noInline(varTest);
function letTest(nb) {
  for (let j = 0; j < nb; j++) { };
}
noInline(letTest);

const nb = 1000 * 1000 * 1000;

for (var i = 0; i < 10; ++i) {
    varTest(nb);
    letTest(nb);
}

const t0 = Date.now();
varTest(nb);
const t1 = Date.now();
letTest(nb);
const t2 = Date.now();
const resVar = Math.floor(t1 - t0);
const resLet = Math.floor(t2 - t1);

print(`Looping ${nb} times with 'var' took ${resVar}ms.\nLooping ${nb} times with 'let' took ${resLet}ms.`);
```

Then the result is the same.

Looping 1000000000 times with 'var' took 241ms.
Looping 1000000000 times with 'let' took 237ms.

Closing this as it is the same.

-- 
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/14cfb8d6/attachment.htm>


More information about the webkit-unassigned mailing list