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/118.0.0.0 Safari/537.36
Browser:
Chrome 118
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
global method lookup
2457506.8 Ops/sec
bound own method
2648275.8 Ops/sec
global method lookup w/cache
3352711.0 Ops/sec
bound own method w/cache
3797293.2 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();