Bug 151233 - Set existence with numeric values slower than numeric object property existence
Summary: Set existence with numeric values slower than numeric object property existence
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-12 16:34 PST by Joseph Pecoraro
Modified: 2015-11-12 16:34 PST (History)
3 users (show)

See Also:


Attachments
[TEST] Set Existence Benchmark (2.49 KB, text/html)
2015-11-12 16:34 PST, Joseph Pecoraro
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2015-11-12 16:34:17 PST
Created attachment 265448 [details]
[TEST] Set Existence Benchmark

* SUMMARY
Set existence with numeric values slower than numeric object property existence.

In Web Inspector we were converting a bunch of uses of "Object as Set" and "Object as Map" to Set/Map objects. I wrote a small benchmark to compare possible performance differences. Existence checks for large dense Sets with primitives is worse than existence checks in large dense Objects.

    object[number]    - 17ms
    number in object  - 84ms
    set.has(number)   - 622ms

For numeric keys object was significantly faster than Set.
For other key types the effect was not as large.

See attached test case.

* NOTES
- Not sure how realistic the test is for real world code. Especially given Set's major advantage is non-primitive keys.