{"ScriptPreparationCode":"var bench1buffer;\r\nvar bench2buffer;\r\nvar bench3buffer;\r\nvar size = 1_000_000;\r\n{\r\n const stride = 10;\r\n bench1buffer = new ArrayBuffer(stride * size);\r\n /*\r\n 0 u16 id\r\n 2 f32 x\r\n 6 f32 y\r\n */\r\n for (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const struct = new DataView(bench1buffer, i * stride, stride);\r\n struct.setUint16(0, i, true);\r\n struct.setFloat32(2, i, true);\r\n struct.setFloat32(6, i * 2, true);\r\n }\r\n}\r\n{\r\n const stride = 12;\r\n bench2buffer = new ArrayBuffer(stride * size);\r\n /*\r\n 0 u16 id\r\n 4 f32 x\r\n 8 f32 y\r\n */\r\n for (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const struct = new DataView(bench2buffer, i * stride, stride);\r\n struct.setUint16(0, i, true);\r\n struct.setFloat32(4, i, true);\r\n struct.setFloat32(8, i * 2, true);\r\n }\r\n}\r\n{\r\n bench3buffer = {\r\n id: new Uint16Array(size),\r\n x: new Float32Array(size),\r\n y: new Float32Array(size),\r\n };\r\n for (let i = 0; i \u003C size; i\u002B\u002B) {\r\n bench3buffer.id[i] = i;\r\n bench3buffer.x[i] = i;\r\n bench3buffer.y[i] = i * 2;\r\n }\r\n}\r\n","TestCases":[{"Name":"DataView AoS","Code":"const stride = 10;\r\n/*\r\n 0 u16 id\r\n 2 f32 x\r\n 6 f32 y\r\n*/\r\nlet sum = 0;\r\nfor (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const struct = new DataView(bench1buffer, i * stride, stride);\r\n const id = struct.getUint16(0, true);\r\n const x = struct.getFloat32(2, true);\r\n const y = struct.getFloat32(6, true);\r\n sum \u002B= id \u002B x * y;\r\n}\r\nconsole.log(1, sum);","IsDeferred":false},{"Name":"DataView byte-aligned AoS","Code":"const stride = 12;\r\n/*\r\n 0 u16 id\r\n 4 f32 x\r\n 8 f32 y\r\n*/\r\nlet sum = 0;\r\nfor (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const struct = new DataView(bench2buffer, i * stride, stride);\r\n const id = struct.getUint16(0, true);\r\n const x = struct.getFloat32(4, true);\r\n const y = struct.getFloat32(8, true);\r\n sum \u002B= id \u002B x * y;\r\n}\r\nconsole.log(2, sum);","IsDeferred":false},{"Name":"TypedArray byte-aligned AoS","Code":"const stride = 12;\r\n/*\r\n 0 u16 id\r\n 4 f32 x\r\n 8 f32 y\r\n*/\r\nconst f32s = new Float32Array(bench2buffer);\r\nconst u16s = new Uint16Array(bench2buffer);\r\nlet sum = 0;\r\nfor (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const offset = i * stride;\r\n const id = u16s[offset / 2];\r\n const x = f32s[offset / 4 \u002B 1];\r\n const y = f32s[offset / 4 \u002B 2];\r\n sum \u002B= id \u002B x * y;\r\n}\r\nconsole.log(3, sum);","IsDeferred":false},{"Name":"TypeArray SoA","Code":"let sum = 0;\r\nconst idbuf = bench3buffer.id;\r\nconst xbuf = bench3buffer.x;\r\nconst ybuf = bench3buffer.y;\r\nfor (let i = 0; i \u003C size; i\u002B\u002B) {\r\n const id = idbuf[i];\r\n const x = xbuf[i];\r\n const y = ybuf[i];\r\n sum \u002B= id \u002B x * y;\r\n}\r\nconsole.log(3, sum);","IsDeferred":false}]}