BiSON (v8)

Revision 8 of this benchmark created by DrSlump on


Description

Testing: Heavy branching, string stuff, shifting, array / object iteration, array / object creation, charCodeAt etc.

Preparation HTML

<script type="text/javascript" src="https://github.com/BonsaiDen/BiSON.js/raw/master/bison.js"></script>
<script>
  var encoded, decoded;
  var ints = [],
      floats = [],
      dicts = [],
      arrays = [],
      bools = [],
      strings = [];
  for (var i = 0; i < 30; i++) {
   ints.push(0);
   ints.push(1);
   ints.push(-5);
   ints.push(1000);
   ints.push(-2500);
   ints.push(1000000);
   ints.push(-2500000);
   ints.push(2147483647);
   ints.push(-2147483647);
  
   floats.push(0.24);
   floats.push(1.12);
   floats.push(-5.98);
   floats.push(1000.45);
   floats.push(-2500.37);
   floats.push(1000000.12);
   floats.push(-2500000.64);
   floats.push(2147483647.01);
   floats.push(-2147483647.99);
  
   dicts.push({});
   dicts.push({
    'a': {},
    'b': {}
   });
   dicts.push({
    'c': {
     'f': {}
    },
    'd': {}
   });
  
   arrays.push([]);
   arrays.push([
    [],
    [],
    []
   ]);
   arrays.push([
    [],
    [
     [],
     []
    ],
    [
     [],
     []
    ]
   ]);
  
   bools.push(true);
   bools.push(false);
   bools.push(null);
   bools.push(true);
   bools.push(false);
   bools.push(null);
   bools.push(true);
   bools.push(false);
   bools.push(null);
   bools.push(true);
   bools.push(false);
   bools.push(null);
  
   strings.push('Foo');
   strings.push('Hello World Hello World');
   strings.push('The cake is a lie... The cake is a lie... The cake is a lie...');
   strings.push('Hey listen! Hey listen!Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen! Hey listen!Hey listen! Hey listen! Hey listen!  Hey listen!Hey listen! Hey listen! Hey listen! Hey listen!Hey listen!Hey listen!Hey listen!vHey listen!Hey listen!Hey listen!Hey listen!Hey listen!Hey listen!Hey listen!Hey listen!Hey listen!Hey listen!Hey listen!');
  }
  var intsE = BISON.encode(ints),
      floatsE = BISON.encode(floats),
      dictsE = BISON.encode(dicts),
      arraysE = BISON.encode(arrays),
      boolsE = BISON.encode(bools),
      stringsE = BISON.encode(strings);
  
  var intJ = JSON.stringify(ints),
      floatsJ = JSON.stringify(floats),
      dictsJ = JSON.stringify(dicts),
      arraysE = JSON.stringify(arrays),
      boolsJ = JSON.stringify(bools),
      stringsJ = JSON.stringify(strings);
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Integer Encoding
encoded = BISON.encode(ints);
ready
Integer decoding
decoded = BISON.decode(intsE);
ready
Float encoding
encoded = BISON.encode(floats);
ready
Float decoding
decoded = BISON.decode(floatsE);
ready
Array Encoding
encoded = BISON.encode(arrays);
ready
Array Decoding
decoded = BISON.decode(arraysE);
ready
Object Encoding
encoded = BISON.encode(dicts);
ready
Object decoding
decoded = BISON.decode(dictsE);
ready
Boolean Encoding
encoded = BISON.encode(bools);
ready
Boolean Decoding
decoded = BISON.decode(boolsE);
ready
String encoding
encoded = BISON.encode(strings);
ready
String decoding
decoded = BISON.decode(stringsE);
ready
Json String decoding
decoded = JSON.parse(stringsJ);
ready
Json String encoding
encoded = JSON.stringify(strings);
ready
Json Object encoding
encoded = JSON.stringify(dicts);
ready
JSON Object decoding
decoded = JSON.parse(dictsJ);
ready

Revisions

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