structuredClone vs JSON

Benchmark created on


Setup

const data = {
    "user": {
        "id": 1,
        "username": "johndoe",
        "email": "johndoe@example.com",
        "profile": {
            "first_name": "John",
            "last_name": "Doe",
            "age": 30,
            "gender": "male",
            "address": {
                "street": "123 Main St",
                "city": "Anytown",
                "state": "CA",
                "zipcode": "12345",
                "country": "USA"
            },
            "contact": {
                "home_phone": "555-5555",
                "cell_phone": "555-5556",
                "emergency_contact": {
                    "name": "Jane Doe",
                    "relationship": "spouse",
                    "phone": "555-5557"
                }
            }
        },
        "preferences": {
            "newsletter": true,
            "notifications": {
                "email": true,
                "sms": false,
                "push": true
            },
            "theme": "dark"
        },
        "settings": {
            "privacy": {
                "profile_visible": true,
                "last_seen": "friends",
                "read_receipts": false
            },
            "security": {
                "two_factor_authentication": true,
                "login_alerts": true
            },
            "language": "en-US",
            "timezone": "PST"
        },
        "membership": {
            "plan": "premium",
            "joined_date": "2021-01-15",
            "renewal_date": "2022-01-15",
            "payment_method": "credit_card"
        }
    },
    "activity": {
        "last_login": "2023-10-05T10:00:00Z",
        "recent_purchases": [
            {
                "id": 101,
                "item": "Laptop",
                "price": 1200.99,
                "date": "2023-09-10"
            },
            {
                "id": 102,
                "item": "Headphones",
                "price": 100.00,
                "date": "2023-09-15"
            }
        ],
        "watched_items": [
            {
                "id": 103,
                "item": "Smartphone",
                "price": 899.99
            },
            {
                "id": 104,
                "item": "Tablet",
                "price": 300.00
            }
        ]
    }
}

Test runner

Ready to run.

Testing in
TestOps/sec
structuredClone
structuredClone(data)
ready
JSON
JSON.parse(JSON.stringify(data))
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.