Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
const within vs outside a function
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
const within function
108960.1 Ops/sec
const outside function
109453.5 Ops/sec
Script Preparation code:
var strToConvert = "yr89vi083hf*/:<>?\\|*/:<>?\\|*/:<>?\\|*/:<>?\\|*/:<>?\\|*/:<>?\\|984hijhfgvjhngkjqherkjfherh"; String.prototype.constWithin=function(o,e){ const HW='"*/:<>?\\|',FW='"*/:<>?\\|',FC=String.fromCharCode; return Array.prototype.reduce.call(this, o && Object.hasOwn(o,"char") && (e=o.char, !0) ? (r,c) => r + (HW.includes(c)?e:c) : o?.reverse ? (r,c) => r + (FW.includes(c)?FC(c.charCodeAt(0)-65248):c) : (r,c) => r + (HW.includes(c)?FC(c.charCodeAt(0)+65248):c) , "") } { const HW='"*/:<>?\\|',FW='"*/:<>?\\|',FC=String.fromCharCode; String.prototype.constOutside=function(o,e){ return Array.prototype.reduce.call(this, o && Object.hasOwn(o,"char") && (e=o.char, !0) ? (r,c) => r + (HW.includes(c)?e:c) : o?.reverse ? (r,c) => r + (FW.includes(c)?FC(c.charCodeAt(0)-65248):c) : (r,c) => r + (HW.includes(c)?FC(c.charCodeAt(0)+65248):c) , "") } }
Tests:
const within function
strToConvert.constWithin()
const outside function
strToConvert.constOutside()