{"ScriptPreparationCode":"var bench1buffer;\r\nvar bench2buffer;\r\nvar bench3buffer;\r\nvar size = 1_000_000;\r\n{\r\n const stride = 18;\r\n bench1buffer = new ArrayBuffer(stride * size);\r\n /*\r\n 0 u16 id\r\n 2 f64 x\r\n 10 f64 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.setFloat64(2, i, true);\r\n struct.setFloat64(10, i * 2, true);\r\n }\r\n}\r\n{\r\n const stride = 24;\r\n bench2buffer = new ArrayBuffer(stride * size);\r\n /*\r\n 0 u16 id\r\n 8 f64 x\r\n 16 f64 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.setFloat64(8, i, true);\r\n struct.setFloat64(16, i * 2, true);\r\n }\r\n}\r\n{\r\n bench3buffer = {\r\n id: new Uint16Array(size),\r\n x: new Float64Array(size),\r\n y: new Float64Array(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 = 18;\r\n/*\r\n 0 u16 id\r\n 2 f64 x\r\n 10 f64 y\r\n*/\r\nconst view = new DataView(bench1buffer);\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 = view.getUint16(offset, true);\r\n const x = view.getFloat64(offset \u002B 2, true);\r\n const y = view.getFloat64(offset \u002B 10, 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 = 24;\r\n/*\r\n 0 u16 id\r\n 8 f64 x\r\n 16 f64 y\r\n*/\r\nconst view = new DataView(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 = view.getUint16(offset, true);\r\n const x = view.getFloat64(offset \u002B 8, true);\r\n const y = view.getFloat64(offset \u002B 16, 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 = 24;\r\n/*\r\n 0 u16 id\r\n 8 f64 x\r\n 16 f64 y\r\n*/\r\nconst f64s = new Float64Array(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 = f64s[offset / 8 \u002B 1];\r\n const y = f64s[offset / 8 \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(4, sum);","IsDeferred":false}]}