Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Converting Array to Object
(version: 0)
Comparing performance of:
Object.fromEntries() vs Array.prototype.reduce() vs Assignment
Created:
2 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var arr1 = [ [ "are", "relatively" ], [ "bodies", "that" ], [ "up", "of" ], [ "hot,", "glowing" ], [ "gases.", "They" ], [ "in", "the" ], [ "numbers", "throughout" ], [ "the", "beauty" ], [ "each", "one" ], [ "shining", "with" ], [ "its", "ever-changing" ], [ "unique", "brightness." ], [ "Stars", "also" ], [ "sizes,", "ranging" ], [ "from", "small" ], [ "and", "wonder" ], [ "to", "something" ], [ "They", "remind" ], [ "a", "clear" ], [ "role", "in" ], [ "serving", "as" ], [ "blocks", "of" ], [ "galaxies", "and" ], [ "of", "the" ], [ "for", "navigation," ], [ "on", "Earth." ], [ "have", "looked" ], [ "colors,", "which" ], [ "indicate", "their" ], [ "temperature", "and" ], [ "age.", "Some" ], [ "stars,", "with" ], [ "our", "modern" ], [ "close", "to" ], [ "us,", "while" ], [ "others", "are" ], [ "billions", "of" ], [ "light-years", "away," ], [ "making", "them" ], [ "appear", "as" ], [ "tiny", "points" ], [ "night", "or" ], [ "The", "moon" ], [ "known", "as" ], [ "astronomy,", "allows" ], [ "us", "to" ], [ "learn", "more" ], [ "about", "the" ], [ "universe", "and" ], [ "within", "it." ], [ "since", "the" ], [ "beginning", "of" ], [ "time.", "These" ], [ "celestial", "bodies" ], [ "countless", "myths," ], [ "stories,", "and" ], [ "poems.", "The" ], [ "their", "twinkling" ], [ "light,", "have" ], [ "been", "a" ], [ "helping", "sailors" ], [ "find", "their" ], [ "way", "in" ], [ "world.", "They" ], [ "source", "of" ], [ "guidance", "and" ], [ "hope", "for" ], [ "those", "lost" ], [ "darkness.", "The" ], [ "moon,", "with" ], [ "glow,", "has" ], [ "cultures.", "It" ], [ "has", "also" ], [ "worshiped", "as" ], [ "with", "all" ], [ "symbol", "of" ], [ "change", "and" ], [ "transformation,", "with" ], [ "shape", "and" ], [ "influence", "on" ], [ "tides", "and" ], [ "nature.", "Throughout" ], [ "history,", "people" ], [ "stars", "on" ], [ "moon", "rise" ], [ "answers", "and" ], [ "guidance,", "seeking" ], [ "universe.", "And" ], [ "even", "today," ], [ "technology", "and" ], [ "knowledge,", "the" ], [ "remind", "us" ], [ "small", "place" ], [ "vastness", "of" ], [ "look", "beyond" ], [ "ourselves", "and" ], [ "world", "around" ], [ "us.", "Whether" ], [ "it's", "gazing" ], [ "at", "the" ], [ "watching", "the" ], [ "over", "the" ], [ "horizon,", "these" ], [ "connect", "us" ], [ "greater", "and" ], [ "awe-inspiring", "power" ] ]
Tests:
Object.fromEntries()
Object.fromEntries(arr1)
Array.prototype.reduce()
arr1.reduce((accumulator, currentValue) => { accumulator[currentValue[0]] = currentValue[1] return accumulator }, {})
Assignment
const obj = {} arr1.forEach((value) => { obj[value[0]] = value[1] })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Object.fromEntries()
Array.prototype.reduce()
Assignment
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Object.fromEntries()
121732.7 Ops/sec
Array.prototype.reduce()
220156.9 Ops/sec
Assignment
222924.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll answer the questions based on the provided input. The input appears to be a JSON object with three properties: `arr1`, `Html Preparation Code`, and a list of test cases. To solve this problem, I need more context or information about what is being asked. However, based on the available data, here are some observations: * The `arr1` property contains an array of strings, where each string appears to be a key-value pair in the format `[key, value]`. * The `Html Preparation Code` property is currently empty. * The list of test cases contains three entries, each with a "Benchmark Definition" and a "Test Name". These appear to be benchmarks for comparing the performance of different JavaScript methods: `Object.fromEntries()`, `Array.prototype.reduce()`, and assignment. Without more context or information about what specific problem is being asked, I'll provide some general insights: * The use of `arr1` suggests that we might need to process an array of key-value pairs. * The presence of the `Html Preparation Code` property implies that there might be a related issue with HTML code preparation. If you could provide more context or clarify what specific problem is being asked, I'd be happy to try and assist further.
Related benchmarks:
Array Assignment
array push
Object to Arrays
Array: get last item
array.length = 0 vs []
Comments
Confirm delete:
Do you really want to delete benchmark?