Skip to content

Instantly share code, notes, and snippets.

@alexanderankin
Created March 17, 2023 07:45
Show Gist options
  • Select an option

  • Save alexanderankin/7f631ae01a075f41df404f5cf3727239 to your computer and use it in GitHub Desktop.

Select an option

Save alexanderankin/7f631ae01a075f41df404f5cf3727239 to your computer and use it in GitHub Desktop.

to run this benchmark, go to https://jsbench.me and copy the below inputs:

Setup Javascript:

let random = () => (Math.random() + 1).toString(36).substring(7);
let dummyArray = Array(10000).fill(null).map(random)
let dummySet = new Set(Array(10000).fill(null).map(random))

Test case #1

let newSet = new Set(dummySet)
if (newSet.size !== dummySet.size) throw new Error('count different')

Test case #2

let newSet = dummyArray.slice()
if (newSet.length !== dummyArray.length) throw new Error('count different')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment