BiSON (v3)

Revision 3 of this benchmark created by Ivo Wetzel on


Description

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

Preparation HTML

<script type="text/javascript" src="//dl.dropbox.com/u/2332843/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);
</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

Revisions

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