DEV Community

Discussion on: JavaScript Katas: Remove duplicates

Collapse
 
harrisgca profile image
Glenn Harris

jsben.ch/Uvedk

Performance comparison

  1. For loop
  2. new Set
  3. reduce()
Collapse
 
miku86 profile image
miku86

Thanks Glenn!

When I run the test,
my results differ from yours:

  1. For: 100%
  2. Reduce: 90%
  3. Set: 76%

Do you know something about the internals of the benchmark?

Collapse
 
harrisgca profile image
Glenn Harris

Unfortunately I don't know anything about the internals, even after some research. The results I listed above were in Chrome browser, so I reran the tests in Firefox and Safari and got wildly different results.

Firefox v78.0.2

  1. For (100%)
  2. Reduce (73%)
  3. Set (65%)

Safari v13.1.2

  1. For (100%)
  2. Reduce (64%)
  3. Set (18%)

Chrome 84.4.04

  1. For (100%)
  2. Set (78%)
  3. Reduce (37%)