Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
checking string interpolation vs cache
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/128.0.0.0 Safari/537.36 Edg/128.0.0.0
Browser:
Chrome 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Simple interpolation
302168.8 Ops/sec
With Cache
464343.9 Ops/sec
Script Preparation code:
var randomString = "randomString_";
Tests:
Simple interpolation
for (let i = 0; i < 50; i++) { const ans = `${randomString}${i}`; } for (let i = 0; i < 50; i++) { const ans = `${randomString}${i}`; }
With Cache
const cache = {}; for (let i = 0; i < 50; i++) { if (cache[i]) { const ans1 = cache[i]; } else { const ans = `${randomString}${i}`; cache[i] = ans; } } for (let i = 0; i < 50; i++) { if (cache[i]) { const ans1 = cache[i]; } else { const ans = `${randomString}${i}`; cache[i] = ans; } }