Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Typeof GlobalThis Check
Memoizing a key typeof check in high frequency
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0
Browser:
Firefox 89
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Memoize typeof call
451.8 Ops/sec
Call typeof every time
480.6 Ops/sec
Tests:
Memoize typeof call
let cachedGlobal; function getGlobal() { if (cachedGlobal) { return cachedGlobal; } if (typeof globalThis !== 'undefined' && globalThis) { cachedGlobal = globalThis; } return cachedGlobal } for (let i = 0; i < 4000; i++) { const global = getGlobal(); }
Call typeof every time
function getGlobal() { if (typeof globalThis !== 'undefined' && globalThis) { return globalThis; } } for (let i = 0; i < 4000; i++) { const global = getGlobal(); }