Fake JSON parse

Benchmark created by Fabio Crisci on


Description

Test the creation of a JS Object from a "fake" json, it's not actually JSON but the JS Object notation

Preparation HTML

<script>
  var small = "{some : 12, thing: "
  goes ", here : ["
  one ", "
  two ", "
  three "]}"
  
  var big = {
   bigger: {
    object: {
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    },
    repeat: [{
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    },
    {
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    },
    {
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    },
    {
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    },
    {
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    },
    {
     can: ["contain", "several", "other",
     {
      obje: "cts"
     }],
     just: {
      check: ["that", "both",
      {
       the: "methods"
      }, "works",
      {
       even: {
        when: {
         there: "are"
        },
        big: "objects"
       }
      }]
     },
     number: 12
    }]
   }
  };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Small - Eval
json = (eval(small));
ready
Small - Function
json = (new Function("return " + small))();
ready
Big - Eval
json = (eval(big));
ready
Big - Function
json = (new Function("return " + big))();
ready

Revisions

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

  • Revision 1: published by Fabio Crisci on
  • Revision 2: published by Fabio Crisci on