Javascript DIS Native vs JSON (v2)

Revision 2 of this benchmark created by Don McGregor on


Preparation HTML

<script src="https://www.movesinstitute.org/~mcgredo/js/dis.js"></script>

Setup

// A somewhat typical DIS Entity State PDU
  var disData = new Uint8Array([6, 1, 1, 1, -125, 18, 91, -13, 144, -112, 0, 44, 0, 0, 0, 1, 2, 57, 0, 0, 1, 1, 0, -31, 1, 1, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 65, 72, -63, 32, 49, 83, -5, 65, 81, -117, 100, -34, -54, -31, -53, 65, 76, -39, -92, -36, -81, -65, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  
  var ab = new ArrayBuffer(144);
  var dv = new Uint8Array(ab);
  var idx = 0;
  for(idx = 0; idx < 144; idx++)
  {
    dv[idx] = disData[idx];
  };
  
  // JSON format DIS
   var disText = '{"protocolVersion":6,"exerciseID":0,"pduType":1,"protocolFamily":1,"timestamp":0,"pduLength":0,"padding":0,"entityID":{"site":0,"application":0,"entity":0},"forceId":0,"numberOfArticulationParameters":0,"entityType":{"entityKind":0,"domain":0,"country":0,"category":0,"subcategory":0,"spec":0,"extra":0},"alternativeEntityType":{"entityKind":0,"domain":0,"country":0,"category":0,"subcategory":0,"spec":0,"extra":0},"entityLinearVelocity":{"x":0,"y":0,"z":0},"entityLocation":{"x":0,"y":0,"z":0},"entityOrientation":{"psi":0,"theta":0,"phi":0},"entityAppearance":0,"deadReckoningParameters":{"deadReckoningAlgorithm":0,"otherParameters":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"entityLinearAcceleration":{"x":0,"y":0,"z":0},"entityAngularVelocity":{"x":0,"y":0,"z":0}},"marking":{"characterSet":0,"characters":[0,0,0,0,0,0,0,0,0,0,0]},"capabilities":0,"articulationParameters":[]}';

Test runner

Ready to run.

Testing in
TestOps/sec
JSON format DIS Text, via Eval
var disDataEvalJSON = eval( "(" + disText + ")" );
ready
IEEE 1278.1 Binary DIS
var espdu = new dis.EntityStatePdu();
var is = new dis.InputStream(ab);
espdu.initFromBinaryDIS(is);
ready
JSON format DIS Text, via Native JSON Parser
var disDataNativeJSON = JSON.parse(disText);
ready
IEEE 1278.1, Binary DIS Fast ESPDU
var fespdu = new dis.FastEntityStatePdu();
var fis = new dis.InputStream(ab);
fespdu.initFromBinaryDIS(fis);
ready

Revisions

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

  • Revision 1: published by Don McGregor on
  • Revision 2: published by Don McGregor on