Array Buffer to Base64

Benchmark created by Michael Busby on


Preparation HTML

<script>
window.testDataPromise = fetch('https://secure.gravatar.com/avatar/53ea8d0bccb72fcdd4068e407af5b456')
  .then(function(res) { 
    return res.arrayBuffer();
  }).then(function(arb) {
    return new Uint8Array(arb);
});</script>

Test runner

Ready to run.

Testing in
TestOps/sec
load test data
// Make sure test data is ready for actual cases
testDataPromise.then(function() { deferred.resolve(); });
ready
append
testDataPromise.then(function(data) {
  return btoa(
    data.reduce(function(data, byte) {
      return data + String.fromCharCode(byte);
    }, '')
  );
}).then(function() { deferred.resolve(); });
ready
map+join
testDataPromise.then(function(data) {
  return btoa(
    data.map(function(byte) {
      return String.fromCharCode(byte);
    }).join('')
  );
}).then(function() { deferred.resolve(); });
ready

Revisions

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

  • Revision 1: published by Michael Busby on