Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
lodash.mapKeys vs Native
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Browser:
Safari 17
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Object.keys with for loop
2.1M/s
Object.entries with for loop
987K/s
Object.keys with reduce
979K/s
lodash.mapKeys
971K/s
View exact numbers
Test name
Executions per second
✓
Object.keys with for loop
2,133,634 Ops/sec
Object.entries with for loop
986,887 Ops/sec
Object.keys with reduce
978,718 Ops/sec
lodash.mapKeys
970,692 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
var value = {a: 30310, b: 100303, c: 3040494};
Tests:
lodash.mapKeys
const f = v => _.mapKeys(v, k => k + '-changed') f(value);
Object.keys with for loop
const f = v => { const m = {}; for (const k of Object.keys(v)) m[k + '-changed'] = v[k]; return m; } f(value)
Object.entries with for loop
const f = obj => { const m = {}; for (const [k, v] of Object.entries(obj)) m[k + '-changed'] = v; return m; } f(value)
Object.keys with reduce
const f = obj => Object.keys(obj).reduce( (acc, k) => ({ ...acc, [k + '-changed']: obj[k] }), {} ); f(value)