Bug 155146

Summary: Array destructuring is very slow
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: fpizlo, ggaren, joepeck, keith_miller, saam, ysuzuki
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
[TEST] Array Destructuring Benchmark none

Joseph Pecoraro
Reported 2016-03-07 16:09:49 PST
Created attachment 273235 [details] [TEST] Array Destructuring Benchmark * SUMMARY Array destructuring is very slow. There is a 20x performance difference between using destructuring with Arrays versus not. Object destructuring does not seem to have this cost. [Log] Array - Normal - 2ms [Log] Array - Destructuring - 48ms [Log] Object - Normal - 2ms [Log] Object - Destructuring - 1ms * TEST (full test attached) bench("Array - Normal", function(arr) { var sum = 0; for (var i = 0; i < arr.length; ++i) { var list = arr[i]; var a = list[0], b = list[1], c = list[2], d = list[3], e = list[4]; sum += (a + b + c + d + e); } return sum; }, listOfLists); bench("Array - Destructuring", function(arr) { var sum = 0; for (var i = 0; i < arr.length; ++i) { var [a, b, c, d, e] = arr[i]; sum += (a + b + c + d + e); } return sum; }, listOfLists);
Attachments
[TEST] Array Destructuring Benchmark (1.64 KB, text/html)
2016-03-07 16:09 PST, Joseph Pecoraro
no flags
Joseph Pecoraro
Comment 1 2017-03-06 13:29:54 PST
In Safari Technology Preview array destructuring has improved greatly! However it is still considerably slower than normal array access: (~7x down from ~20x). [Log] Array - Normal - 2ms [Log] Array - Destructuring - 15ms [Log] Object - Normal - 1ms [Log] Object - Destructuring - 1ms
Saam Barati
Comment 2 2017-03-07 10:42:04 PST
(In reply to comment #1) > In Safari Technology Preview array destructuring has improved greatly! > However it is still considerably slower than normal array access: (~7x down > from ~20x). > > [Log] Array - Normal - 2ms > [Log] Array - Destructuring - 15ms > [Log] Object - Normal - 1ms > [Log] Object - Destructuring - 1ms I think we really need more comprehensive support for making the iterator protocol fast. Whatever we do to make for-of faster, should also make this faster.
Saam Barati
Comment 3 2017-03-07 10:43:07 PST
*** This bug has been marked as a duplicate of bug 169030 ***
Note You need to log in before you can comment on or make changes to this bug.