TypedArray

Benchmark created on


Description

compare typedarray with standard array in random access and linear access

Setup

var Uint32 = new Uint32Array(0x10000);
var arr = [];
for (var i = 0x10000 - 1; i >= 0; --i) {
  Uint32[Math.random() * 0x10000 | 0] = (Math.random() * 0x100000000) | 0;
  arr[Math.random() * 0x10000 | 0] = (Math.random() * 0x100000000) | 0;
}
var sum = 0;

Test runner

Ready to run.

Testing in
TestOps/sec
normal array random access

for (var i = 0x10000 - 1; i >= 0; --i) {
	sum = arr[ (Math.random() * 0x10000) | 0];
}
ready
typed array random access
for (var i = 0x10000 - 1; i >= 0; --i) {
	sum = Uint32[ (Math.random() * 0x10000) | 0];
}
ready
normal array linear access
for (var i = 0x10000 - 1; i >= 0; --i) {
	sum = arr[ i];
}
ready
typedarray linear access
for (var i = 0x10000 - 1; i >= 0; --i) {
	sum = Uint32[ i];
}
ready

Revisions

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