Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Looping Frozen object: Object Freeze vs Deep Freeze vs Without Object Freeze vs
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 131
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Loop Frozen Object
2083.6 Ops/sec
Loop Deep-Frozen Object
1938.7 Ops/sec
Loop Non-Frozen Object
1825.8 Ops/sec
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 deepFreeze = obj => { for (const key in obj) { if (obj.hasOwnProperty(key) && typeof obj[key] === "object" && obj[key] !== null) { deepFreeze(obj[key]) } } return Object.freeze(obj) } const frozenObject = Object.freeze(structuredClone(birdSpecies)) const copy = structuredClone(birdSpecies) const deepFrozenObject = deepFreeze(copy) const nonFrozenObject = structuredClone(birdSpecies)
Tests:
Loop Frozen Object
for (const [habitat, data] of Object.entries(frozenObject)) { console.log(`Habitat: ${habitat}`) for (const bird of data.species) { console.log(` Name: ${bird.name}`) console.log(` Physical Characteristics:`) for (const [key, value] of Object.entries(bird.physicalCharacteristics)) { console.log(` ${key}: ${value}`) } console.log(` Diet:`) for (const [key, value] of Object.entries(bird.diet)) { console.log(` ${key}: ${value}`) } console.log(` Habitat: ${bird.habitat}`) } }
Loop Deep-Frozen Object
for (const [habitat, data] of Object.entries(deepFrozenObject)) { console.log(`Habitat: ${habitat}`) for (const bird of data.species) { console.log(` Name: ${bird.name}`) console.log(` Physical Characteristics:`) for (const [key, value] of Object.entries(bird.physicalCharacteristics)) { console.log(` ${key}: ${value}`) } console.log(` Diet:`) for (const [key, value] of Object.entries(bird.diet)) { console.log(` ${key}: ${value}`) } console.log(` Habitat: ${bird.habitat}`) } }
Loop Non-Frozen Object
for (const [habitat, data] of Object.entries(nonFrozenObject)) { console.log(`Habitat: ${habitat}`) for (const bird of data.species) { console.log(` Name: ${bird.name}`) console.log(` Physical Characteristics:`) for (const [key, value] of Object.entries(bird.physicalCharacteristics)) { console.log(` ${key}: ${value}`) } console.log(` Diet:`) for (const [key, value] of Object.entries(bird.diet)) { console.log(` ${key}: ${value}`) } console.log(` Habitat: ${bird.habitat}`) } }