Script Preparation code:
x
 
function simpleStringify(o) {
  let cache = [];
  let data = JSON.stringify(o, function(key, value) {
    if (typeof value === "object" && value !== null) {
      if (cache.indexOf(value) !== -1) {
        // Circular reference found, discard key
        return;
      }
      // Store value in our collection
      cache.push(value);
    }
    return value;
  });
  cache = null;
  return data;
}
function verySimpleStringify(o) {
    return "{bar:" + o.foo + "}"
}
var testData = {"bar":"foo"}
Tests:
  • verySimpleStringify

     
    verySimpleStringify(testData);
  • simpleStringify

     
    simpleStringify(testData);
  • JSON.stringify

     
    JSON.stringify(testData)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    verySimpleStringify
    simpleStringify
    JSON.stringify

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36 Edg/91.0.864.71
Chrome 91 on Windows
View result in a separate tab
Test name Executions per second
verySimpleStringify 4296300.5 Ops/sec
simpleStringify 785889.6 Ops/sec
JSON.stringify 1505813.0 Ops/sec