reduce vs object from entries (v3)

Revision 3 of this benchmark created on


Setup

var data = { ...Array.from(Array(10000).keys()) };

Test runner

Ready to run.

Testing in
TestOps/sec
filter
Object.fromEntries(Object.entries(data).filter((d) => d[1]));
ready
reduce
  Object.entries(data).reduce(
    (acc, [key, value]) =>
      value === undefined ? acc : { ...acc, [key]: value },
    {}
  );
ready
array push
const res={}
Object.entries(data).forEach(([key, value])=>{
	if(value){
		res[key]=value
	}
})
ready
set
  const res = new Map();
  Object.entries(data).forEach(([key, value]) => {
    if (value) {
      res.set(key, value);
    }
  });
ready

Revisions

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