Uint8ArrayCopy

Benchmark created by Frank Galligan on


Preparation HTML

<script>
  var size = 700000;
  var buffer = new ArrayBuffer(size);
  
  // Fill the buffer with some data.
  var view = new Uint8Array(buffer);
  for (var i = 0; i < size; ++i) {
    view[i] = 0xff;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Uint8Array Copy Constructor
var copy1 = new Uint8Array(view);
ready
For loop copy
var bufferCopy = new ArrayBuffer(view.length);
var copy2 = new Uint8Array(bufferCopy);
var l = copy2.length;
for (i = 0; i < l; ++i) {
  copy2[i] = view[i];
}
ready

Revisions

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

  • Revision 1: published by Frank Galligan on