toSource vs. JSON.stringify

Benchmark created by Nikolay Frantsev on


Setup

var test = {
      foo: 1,
      bar: 2,
      quux: {
        a: [1, 2, 3, 4],
        b: {
          1: 2,
          3: 4
        },
        c: "hello world"
      }
    }

Test runner

Ready to run.

Testing in
TestOps/sec
toSource
var result = test.toSource();
ready
JSON.stringify
var result = JSON.stringify(test);
ready

Revisions

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

  • Revision 1: published by Nikolay Frantsev on