Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Palendrome (Short strings)
(version: 0)
Comparing performance of:
Reverse array comparison vs For loop early exit
Created:
3 years ago
by:
Guest
Jump to the latest result
Tests:
Reverse array comparison
const strings = ['pop', 'noon', 'madam', 'james'] const checkPalendrome = string => { string === [...string].reverse().join('') } for (const string of strings) { console.log(`${string} palendrome = ${checkPalendrome(string)}`) }
For loop early exit
const strings = ['pop', 'noon', 'madam', 'james'] const checkPalendrome = string => { const length = string.length let isPalendrome = true for (let index = 0; index <= length; index++) { const left = string.charAt(index) const right = string.charAt(length - index - 1) isPalendrome = left === right if (!isPalendrome) break } return isPalendrome } for (const string of strings) { console.log(`${string} palendrome = ${checkPalendrome(string)}`) }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Reverse array comparison
For loop early exit
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Diacritics removal (+ lowercase2)
Converting String to Array of Chars
replaceAll vs. adding characters up
abcdfggg
Remove diacritics from string
Comments
Confirm delete:
Do you really want to delete benchmark?