Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object function binding vs closure
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser:
Chrome 126
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
global method lookup
1303613.2 Ops/sec
bound own method
1478247.9 Ops/sec
global method lookup w/cache
2014127.6 Ops/sec
bound own method w/cache
2346823.8 Ops/sec
Script Preparation code:
const QUEUE_1 = new Map([ [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}] ]); const QUEUE_2 = new Map([ [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}] ]); let BUFFER = -1; function run() { QUEUE_1.clear(); QUEUE_2.clear(); } const cancel = window.cancelAnimationFrame; const request = window.requestAnimationFrame; var OBJECT = { _buffer: -1, _queue1: new Map([ [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}] ]), _queue2: new Map([ [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}], [{}, {}] ]), runGlobal() { cancelAnimationFrame(BUFFER); BUFFER = requestAnimationFrame(run); }, runBoundOwn() { cancelAnimationFrame(this._buffer); this._buffer = requestAnimationFrame(this._run); }, runGlobalRafCached() { cancel(BUFFER); BUFFER = request(run); }, runBoundOwnRafCached() { cancel(this._buffer); this._buffer = request(this._run); }, _run() { this._queue1.clear(); this._queue2.clear(); } }; OBJECT._run.bind(OBJECT);
Tests:
global method lookup
OBJECT.runGlobal();
bound own method
OBJECT.runBoundOwn();
global method lookup w/cache
OBJECT.runGlobalRafCached();
bound own method w/cache
OBJECT.runBoundOwnRafCached();