Blob-Base64-Conversion (v7)

Revision 7 of this benchmark created by tatamartino on


Preparation HTML

<span style="font-family: monospace; white-space: pre;">
1 blob to base64 asynchronously
    using FileReader's readAsDataURL
2 blob to base64 asynchronously
    using FileReader's readAsArrayBuffer, String's fromCharCode and btoa
3 base64 to blob synchronously
    using atob, ArrayBuffer, String's charCodeAt and Blob's constructor
</span>

Setup

var blobContent = '';
      for (var i = 0; i < 256 * 256; i++) {
        blobContent += '#';
      }
      var testBlob = new Blob([blobContent]);

Test runner

Ready to run.

Testing in
TestOps/sec
1 Blob to Base64
// async test
var reader = new FileReader();
reader.onload = function() {
  deferred.resolve();
};
reader.readAsDataURL(testBlob);
ready
2 Blob to Base64 (2)
var base64 = window.btoa(testBlob);
ready

Revisions

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