uniquify

Benchmark created on


Setup

const tags = [
  'foo',
  'bar',
  'foo',
  'fizz',
  'buzz',
  'foo',
];
const iterations = 1_000;

Test runner

Ready to run.

Testing in
TestOps/sec
byIndex
const unique = (array) => array.filter(
  (element, index, self) => self.indexOf(element) === index,
);
for (let i = 0; i < iterations; i++) {
	unique(tags);
}
ready
byHash
const unique = (array) => Array.from(new Set(array));
for (let i = 0; i < iterations; i++) {
	unique(tags);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.