Skip to content

Instantly share code, notes, and snippets.

@justjavac
Last active August 17, 2017 05:21
Show Gist options
  • Save justjavac/352fafd93b060ffb5cbe87064d8f46f7 to your computer and use it in GitHub Desktop.
Save justjavac/352fafd93b060ffb5cbe87064d8f46f7 to your computer and use it in GitHub Desktop.
function test() {
const a = new Int32Array(10);
for (let i = 0; i < 1e6; i++) {
a.set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
}
return a;
}
console.time('test');
test();
console.timeEnd('test');
new Int8Array(1).set([0]);
new Uint8Array(1).set(['5']);
new Float32Array(1).set([NaN]);
new Float64Array(1).set([0.1]);
console.time('test');
test();
console.timeEnd('test');
@justjavac
Copy link
Author

The type feedback for the relevant internal function TypedArraySetFromArrayLike is polluted.
https://github.com/v8/v8/blob/e08cdc277ba089ca6ff01682eb877af9b1cdec38/src/js/typedarray.js#L254-L265

@justjavac
Copy link
Author

justjavac commented Aug 17, 2017

V8 性能优化计划:ES2015 and beyond performance plan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment