Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Looping frozen object vs non-frozen object
(version: 1)
Comparing performance of:
Loop frozen object vs Loop non-frozen object
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const birdSpecies = { forest: { species: [ { name: "Northern Cardinal", physicalCharacteristics: { color: "Red", size: "Medium", beakType: "Conical" }, diet: { primary: "Seeds", secondary: "Fruits" }, habitat: "Woodlands and forests" }, { name: "Woodpecker", physicalCharacteristics: { color: "Black, White, and Red", size: "Medium", beakType: "Chisel-shaped" }, diet: { primary: "Insects", secondary: "Tree sap" }, habitat: "Wooded areas" } ] }, desert: { species: [ { name: "Roadrunner", physicalCharacteristics: { color: "Brown and White", size: "Medium", beakType: "Long and Slim" }, diet: { primary: "Insects", secondary: "Small reptiles" }, habitat: "Desert and arid regions" }, { name: "Cactus Wren", physicalCharacteristics: { color: "Brown with streaks", size: "Small", beakType: "Curved" }, diet: { primary: "Insects", secondary: "Seeds" }, habitat: "Cacti and desert shrubs" } ] }, wetlands: { species: [ { name: "Great Blue Heron", physicalCharacteristics: { color: "Blue-gray", size: "Large", beakType: "Long and Sharp" }, diet: { primary: "Fish", secondary: "Amphibians" }, habitat: "Wetlands and marshes" }, { name: "American Coot", physicalCharacteristics: { color: "Dark gray with white bill", size: "Medium", beakType: "Flat and short" }, diet: { primary: "Aquatic plants", secondary: "Small invertebrates" }, habitat: "Lakes and wetlands" } ] } } const frozenObject = Object.freeze(birdSpecies) const nonFrozenObject = birdSpecies
Tests:
Loop frozen object
function doStuff(value) { // } for (const habitat in frozenObject) { const data = frozenObject[habitat]; for (const bird of data.species) { for (const key in bird.physicalCharacteristics) { const value = bird.physicalCharacteristics[key]; doStuff(value); } for (const key in bird.diet) { const value = bird.diet[key]; doStuff(value); } } }
Loop non-frozen object
function doStuff(value) { // } for (const habitat in nonFrozenObject) { const data = frozenObject[habitat]; for (const bird of data.species) { for (const key in bird.physicalCharacteristics) { const value = bird.physicalCharacteristics[key]; doStuff(value); } for (const key in bird.diet) { const value = bird.diet[key]; doStuff(value); } } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Loop frozen object
Loop non-frozen object
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:134.0) Gecko/20100101 Firefox/134.0
Browser/OS:
Firefox 134 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Loop frozen object
5165897.5 Ops/sec
Loop non-frozen object
5155683.0 Ops/sec
Related benchmarks:
for each for of christian
AOC Day 7
Filter vs slice - neokore
Spread vs Object.assign Edu Test
Group by
inherit vs copy
Searching in an array of objects
Looping Frozen object: Object Freeze vs Without Object Freeze
Looping Frozen object: Object Freeze vs Deep Freeze vs Without Object Freeze vs
Comments
Confirm delete:
Do you really want to delete benchmark?