DataView vs. Float64Array vs. native Object vs. native Array: normal (v2)

Revision 2 of this benchmark created on


Description

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

Setup

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

const a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
const o = {a:0, b:0, c:0, d:0, e:0, f:0, g:0, h:0, i:0, j: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(3));
dv.setFloat64(4, dv.getFloat64(1) + dv.getFloat64(4));
dv.setFloat64(5, dv.getFloat64(1) + dv.getFloat64(5));
dv.setFloat64(6, dv.getFloat64(1) + dv.getFloat64(6));
dv.setFloat64(7, dv.getFloat64(1) + dv.getFloat64(7));
dv.setFloat64(8, dv.getFloat64(1) + dv.getFloat64(8));
dv.setFloat64(9, dv.getFloat64(1) + dv.getFloat64(9));
ready
Float64Array
float64[0] = float64[0] + 1;
float64[1] = float64[0] + float64[1];
float64[2] = float64[0] + float64[1];
float64[3] = float64[1] + float64[3];
float64[4] = float64[1] + float64[4];
float64[5] = float64[1] + float64[5];
float64[6] = float64[1] + float64[6];
float64[7] = float64[1] + float64[7];
float64[8] = float64[1] + float64[8];
float64[9] = float64[1] + float64[9];
ready
Array
a[0] = a[0] + 1;
a[1] = a[0] + a[1];
a[2] = a[0] + a[1];
a[3] = a[1] + a[3];
a[4] = a[1] + a[4];
a[5] = a[1] + a[5];
a[6] = a[1] + a[6];
a[7] = a[1] + a[7];
a[8] = a[1] + a[8];
a[9] = a[1] + a[9];

ready
Object
o.a = o.a + 1;
o.b = o.a + o.b;
o.c = o.a + o.b;
o.d = o.b + o.d;
o.e = o.b + o.e;
o.f = o.b + o.f;
o.g = o.b + o.g;
o.h = o.b + o.h;
o.i = o.b + o.i;
o.j = o.b + o.j;

ready

Revisions

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