Uint8Arrat.toString vs atob

Benchmark created on


Setup

const test = new Uint8Array(1000);
for (let i=0; i < 1000; i++) {
	test[i] = Math.floor(Math.random() * 255);
} 

Test runner

Ready to run.

Testing in
TestOps/sec
Uint8Arrat.toString
const string = test.toString();
const array = Uint8Array.from(
      string.split(',').map(x => parseInt(x, 10)),
    );
ready
atob
const string = window.btoa(String.fromCharCode.apply(null, test));
const array = Uint8Array.from(atob(string), c => c.charCodeAt(0))

ready

Revisions

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