Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
string cast vs template literal cast vs cached empty string cast with random values
cast to string or template literal wrapping
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser:
Chrome 143
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
7 months ago
Template literal
279.2M/s
Cast
267.0M/s
Cast cached string
263.0M/s
String literal
261.1M/s
View exact numbers
Test name
Executions per second
✓
Template literal
279,203,776 Ops/sec
Cast
267,000,864 Ops/sec
Cast cached string
263,039,568 Ops/sec
String literal
261,052,592 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); } const TEST_ITERATIONS=100000; const emptyString = '';
Tests:
String literal
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ for (let i=0; i++; i<TEST_ITERATIONS) { const stringLiteral = String(Math.random() + i); }
Template literal
for (let i=0; i++; i<TEST_ITERATIONS) { const templateLiteral = `${Math.random() + i}` }
Cast
for (let i=0; i++; i<TEST_ITERATIONS) { const cast = '' + (Math.random() + i); }
Cast cached string
for (let i=0; i++; i<TEST_ITERATIONS) { const castCached = emptyString + (Math.random() + i); }