You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
console.time('creating a lot of');
// we push to array else v8 can skip the entire loop
const jarvises = [];
for(let i=0; i < 2**24; i++) {
jarvises.push(
new JarvisEmitterInterfaceBuilder()
.name('dynamicName')
.role('someRole')
.sticky(false)
.description('my Description')
.build(),
);
}
console.timeEnd('creating a lot of');
And run it, it takes around ~4200MS
Let's have a look at the constructor:
class JarvisEmitterInterfaceBuilder {
constructor() {
this.object = {};
}
and It will dynamically create the keys name, role etc (v8 unlikes it)
Hey
This is micro optimisation, but still
If I'll take the following loop:
And run it, it takes around
~4200MS
Let's have a look at the constructor:
and It will dynamically create the keys
name
,role
etc (v8 unlikes it)But if I'll pre-create them (v8 likes it)
And run the same loop again, it will take
~1900MS
around 2.2x times fasterThe only question is, can these fields be nullable?
The text was updated successfully, but these errors were encountered: