Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Object.values() vs Array.from() bis
(version: 1)
Comparing performance of:
Object.values() vs Array.from(Map.values())
Created:
4 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function generateID(length = 10) { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; let result = ''; const charactersLength = characters.length; for (let i = 0; i < length; i++) { // Generate a random index based on characters length const randomIndex = Math.floor(Math.random() * charactersLength); // Append the character at the random index to the result string result += characters[randomIndex]; } return result; } const obj = {}; const map = new Map(); for (let i = 0; i < 1000; i++) { const id = generateID(); obj[id] = { key: id }; map.set(id, { key: id }); } const obj2 = map.values();
Tests:
Object.values()
const result = Object.values(obj);
Array.from(Map.values())
const result = Array.from(obj2);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Object.values()
Array.from(Map.values())
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.127 Safari/537.36 OPR/60.3.3004.55692
Browser/OS:
Opera 60 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object.values()
573.1 Ops/sec
Array.from(Map.values())
746114.7 Ops/sec
Related benchmarks:
Lodash _.some vs _.includes vs array.find
Lodash vs vanila 2
.concat() is slow (immutable) vs .push() (mutation)
reduce: spreading acc vs mutating acc
concat vs spread vs push
Object.values() vs Array.from(Map.values())
Lodash _.some vs _.includes vs array.find vs array.some vs _.find
javascript case insensitive compare with -1 0 1 for sorting
lodash difference with long strings
Comments
Confirm delete:
Do you really want to delete benchmark?