js prototype & this performance (v2)

Revision 2 of this benchmark created on


Description

Access this may hurt much in performance

Setup

Number.prototype.add = function (b) {
	return this + b;
}

function add(a, b) {
	return a+b;
}

const aadd = (a, b) => a+b;

Number.prototype.double = function () {
	return this + this;
}

Number.prototype.noop = function () {
}

var a = 2;

Test runner

Ready to run.

Testing in
TestOps/sec
prototype add
a.add(3)
ready
function
add(2,3)
ready
arrow function
aadd(2,3)
ready
prototype double
a.double()
ready
prototype noop
a.noop()
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.