Compare speed of creating a map from an existing map

Benchmark created on


Setup

const mapWithItem = new Map();
mapWithItem.set(1, 'Item 1');

const mapWith1KItems = new Map();
for(let i = 0; i < 1000; i ++) {
	mapWith1KItems.set(i, `Item ${i}`)
}

const mapWith100KItems = new Map();
for(let i = 0; i < 100000; i ++) {
	mapWith100KItems.set(i, `Item ${i}`)
}

Test runner

Ready to run.

Testing in
TestOps/sec
New map from map with 1 Item
const theNewMap = new Map(mapWithItem);
ready
New map from map with 1K items
const theNewMap = new Map(mapWith1KItems);
ready
New map from map with 100K items
const theNewMap = new Map(mapWith100KItems);
ready

Revisions

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