Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Palindrome checker
(version: 0)
Comparing performance of:
simple palindrome vs not palindrome
Created:
9 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
function isPalindrome(input) { if (input.length <= 1) { return true; } else { return (input[0] === input[input.length-1]) && isPalindrome(input.substring(1,input.length-1)); } }
Tests:
simple palindrome
isPalindrome('hannah')
not palindrome
isPalindrome('hanffdfsssnah')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
simple palindrome
not palindrome
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser/OS:
Chrome 132 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
simple palindrome
24393740.0 Ops/sec
not palindrome
19443356.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into explaining the benchmark and its test cases. **Benchmark Overview** The provided JSON represents a JavaScript microbenchmark for checking whether a given string is a palindrome or not. The benchmark is designed to measure the performance of different approaches in determining if a string is a palindrome. **Script Preparation Code** The script preparation code defines a function `isPalindrome(input)` that takes an input string and returns `true` if it's a palindrome, and `false` otherwise. This function uses recursion to compare characters from both ends of the string. If the first character matches the last character, and the substring between them is also a palindrome, then the entire string is a palindrome. Here are some pros and cons of this approach: Pros: * Simple and easy to understand * Uses recursion, which can be efficient for small inputs Cons: * Can be slow for large inputs due to recursive calls * May cause stack overflow errors for very long strings **Library Used** The benchmark doesn't explicitly mention a library used in the script preparation code. However, it's worth noting that some JavaScript engines might have built-in optimizations or features that could affect the performance of this function. **Special JS Feature/Syntax (None)** There are no special JavaScript features or syntax used in this benchmark. **Other Alternatives** For palindromic string checks, alternative approaches include: * Iterative methods: Instead of using recursion, you can use a loop to compare characters from both ends of the string. * Boyer-Moore algorithm: A more efficient algorithm for palindrome detection, but it requires additional memory and is more complex to implement. **Test Cases** The benchmark includes two test cases: 1. "simple palindrome": The input string "hannah" is a palindrome. 2. "not palindrome": The input string "hanffdfsssnah" is not a palindrome. Here are some pros and cons of each approach for these test cases: Pros of the recursive approach for both test cases: * Easy to understand and implement Cons of the recursive approach for the "simple palindrome" test case: * May be slow due to unnecessary recursive calls * Could potentially cause stack overflow errors for very long strings Cons of the recursive approach for the "not palindrome" test case: * Still uses recursion, which might be slow for large inputs * Might not work correctly if the input string is extremely long In comparison, iterative approaches or more specialized algorithms like Boyer-Moore could potentially provide better performance and accuracy for larger inputs. **Benchmark Result** The latest benchmark result shows that Chrome 89 browser on a Desktop with Mac OS X 11.2.3 operating system executes the "simple palindrome" test case approximately 3067 times per second, while executing the "not palindrome" test case approximately 2906 times per second.
Related benchmarks:
Palindrome checker
palindrom test
Local or Global
aa vs bb
Comments
Confirm delete:
Do you really want to delete benchmark?