ArrayBuffer vs Blob on WebSocket

Benchmark created on


Preparation HTML

<canvas id="canvas" width="765" height="501">

Setup

var image = new Image();
        image.onload = function(e){
          document.getElementById("canvas").getContext("2d").drawImage(image,0,0, 765, 501);
        }
        image.src = "http://associationsportive.insa-toulouse.fr/modules/resources/download/as/Partenaires/logo_sii.jpg"
        
        
        var maConnection = new WebSocket('ws://10.6.196.53:8080', ['formationhtml5-protocol']);
    
    maConnection.onmessage = function(e) {
      console.log('On', e);
    };     
    
        function dataURItoBlob(dataURI) {
            var binary = atob(dataURI.split(',')[1]);
            var array = [];
            for(var i = 0; i < binary.length; i++) {
                array.push(binary.charCodeAt(i));
            }
            return new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
        }

Teardown


    maConnection.send("Ping");
  

Test runner

Ready to run.

Testing in
TestOps/sec
ArrayBuffer
maConnection.binaryType = 'arraybuffer';
 
ready
Blob
// async test
maConnection.binaryType = 'blob';
ready

Revisions

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