Skip to content

Instantly share code, notes, and snippets.

@marekpiechut
Last active August 18, 2017 11:31
Show Gist options
  • Select an option

  • Save marekpiechut/96babe8b971284f62f597cd7d7391b10 to your computer and use it in GitHub Desktop.

Select an option

Save marekpiechut/96babe8b971284f62f597cd7d7391b10 to your computer and use it in GitHub Desktop.
Benchmark proto - small
const MyType = function(startVal) {
this.val = startVal
...
}
MyType.prototype.add = function(b) { ... }
MyType.prototype.sub = function(b) { ... }
...
for(let i = 0; i < 1000000; i++) {
objects.push(new MyType(i))
}
let idx = 0
setInterval(() => {
const o = objects[idx]
o.add(12)
o.sub(4)
o.mul(7)
o.mod(16)
idx++
document.getElementById('target-div').innerHTML = o.getVal()
}, 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment