Last active
June 21, 2021 17:17
-
-
Save GiuseppeMP/b9278dc377140599060a82d00449efb7 to your computer and use it in GitHub Desktop.
The computing price of escapping characters in strings that not needed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function testingDoubleQuotes(){ | |
console.time('doublequotes') | |
for (let i = 0; i < 10000000; i++) { | |
const string1 = "String One" | |
} | |
console.timeEnd('doublequotes') | |
} | |
function testingSingleQuotes(){ | |
console.time('singlequotes') | |
for (let i = 0; i < 10000000; i++) { | |
const string2 = 'String Two' | |
} | |
console.timeEnd('singlequotes') | |
} | |
function testingbackticks(){ | |
console.time('backticks') | |
for (let i = 0; i < 10000000; i++) { | |
const string1 = `String Three` | |
} | |
console.timeEnd('backticks') | |
} | |
testingDoubleQuotes() | |
testingSingleQuotes() | |
testingbackticks() | |
/** | |
* doublequotes: 1.936ms | |
* singlequotes: 0.933ms | |
* backticks: 0.924ms | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment