small: DataView vs. native Object vs. native Array

Benchmark created on


Description

Compare the speed of different storage methods of multiple simple double (float64) types

Setup

const buffer = new ArrayBuffer(4*4);
const dv = new DataView(buffer);

const a = [0, 0, 0, 0];
const o = {a:0, b:0, c:0, d:0};

Test runner

Ready to run.

Testing in
TestOps/sec
DataView
dv.setFloat64(0, dv.getFloat64(0) + 1);
dv.setFloat64(1, dv.getFloat64(0) + dv.getFloat64(1));
dv.setFloat64(2, dv.getFloat64(0) + dv.getFloat64(1));
dv.setFloat64(3, dv.getFloat64(1) + dv.getFloat64(2));

ready
Array
a[0] = a[0] + 1;
a[1] = a[0] + a[1];
a[2] = a[0] + a[1];
a[3] = a[1] + a[2];

ready
Object
o.a = o.a + 1;
o.b = o.a + o.b;
o.c = o.a + o.b;
o.d = o.b + o.c;
ready

Revisions

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