Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
rot13test
(version: 0)
Comparing performance of:
FCC vs self
Created:
9 years ago
by:
Guest
Jump to the latest result
Tests:
FCC
function rot13(str) { return str.split('') .map.call(str, function(char) { x = char.charCodeAt(0); if (x < 65 || x > 90) { return String.fromCharCode(x); } else if (x < 78) { return String.fromCharCode(x + 13); } return String.fromCharCode(x - 13); }).join(''); } rot13("SERR PBQR PNZC");
self
function rot13(str) { // LBH QVQ VG! var decode = []; var decodeString = ""; for (i = 0; i < str.length; i++) { decode.push(str.charCodeAt(i)); if (decode[i] >= 78 && decode[i] <= 90) { decode[i] = decode[i] - 13; } else if (decode[i] >= 65 && decode[i] < 78) { decode[i] = decode[i] + 13; } decodeString += String.fromCharCode(decode[i]); } return decodeString; } // Change the inputs below to test rot13("SERR PBQR PNZC");
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
FCC
self
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!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON and analyze what's being tested. **Benchmark Definition** The benchmark definition is a JavaScript function named `rot13` that takes a string as input and returns the ROT13 encrypted version of the string. The encryption process involves shifting each character by 13 positions in the alphabet. **Options Compared** In this benchmark, two different implementations of the `rot13` function are compared: 1. **FCC (Function Call Mapping)**: This implementation uses the `map()` method to apply a transformation function to each character in the string. The transformation function checks if the character's ASCII code is within certain ranges and applies the corresponding shift. 2. **self**: This implementation uses a loop to iterate over each character in the string, pushing its ASCII code onto an array. It then checks if the character falls within specific ranges and applies the corresponding shift. **Pros and Cons** * **FCC (Function Call Mapping)**: + Pros: More concise and expressive, leveraging the `map()` method's power. + Cons: May incur overhead due to function call overhead. * **self**: + Pros: Iterative approach can be more efficient for large strings. + Cons: More verbose and less readable than the FCC implementation. **Library Usage** None of the provided implementations use any external libraries. **Special JS Feature/Syntax** The ROT13 encryption process uses ASCII code values to determine which characters to shift. This is a simple and widely used technique in cryptography. **Other Considerations** * The benchmark focuses on the execution speed of the `rot13` function, likely because it's intended for testing purposes. * The use of fixed-size strings (e.g., "SERR PBQR PNZC") ensures that the benchmark only measures performance for a specific input size. **Alternative Approaches** Other possible approaches to implementing ROT13 encryption could include: 1. Using a lookup table or array to map ASCII codes to shifted values. 2. Employing modular arithmetic to ensure wrapping around the alphabet. 3. Using a more advanced cryptographic algorithm, such as Vigenère ciphers, for improved security. However, these alternatives might add unnecessary complexity and are likely not relevant to this benchmark's focus on execution speed.
Related benchmarks:
rot13342
rot13 test
test dv vs fm real
bmm tests2
Comments
Confirm delete:
Do you really want to delete benchmark?