Clone u8intArray (v5)

Revision 5 of this benchmark created on


Setup

var i = 0
      , len = 1000
      , orig = new Uint8Array(len);
    
    for ( ; i < len; ++i ) {
      orig[i] = 1 - (Math.random() * 2);
    }
    
    function loopClone ( ab ) {
      var i = 0
        , len = ab.length
        , f32 = new Uint8Array(ab.length), i = 0;
      for ( ; i < len; ++i ) {
        f32[i] = ab[i];
      }
      return f32;
    }
    
    function setClone( ab ) {
      var f32 = new Uint8Array(ab.length);
      f32.set(ab);
      return f32;
    }

Test runner

Ready to run.

Testing in
TestOps/sec
Loop
loopClone(orig);
ready
Set
setClone(orig);
ready

Revisions

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