structuredClone vs. JSON.parse/stringify (v2)

Revision 2 of this benchmark created on


Setup

var myObj = {
  description: 'Creates a deep copy of source, which should be an object or an array.',
  myNumber: 123456789,
  myBoolean: true,
  jayson: {
    stringify: 'JSON.stringify() method converts a JavaScript value to a JSON string....',
    parse: 'JSON.parse() method parses a JSON string...'
  },
  myArr: [1,2,3]
};

Test runner

Ready to run.

Testing in
TestOps/sec
structuredClone
var myCopy = structuredClone(myObj)
ready
JSON
var myCopy = JSON.parse(JSON.stringify(myObj))
ready

Revisions

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