Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
large string comparison
(version: 0)
Worst case large string comparison.
Comparing performance of:
1MB string comparison vs 2MB string comparison vs 10MB string comparison
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
let s1MB = "0123456789".repeat(1000*100); var strings1MB = Array.from(Array(20)).map(o=>s1MB + String.fromCharCode(32+~~(Math.random()*96))) let s2MB = "0123456789".repeat(1000*200); var strings2MB = Array.from(Array(20)).map(o=>s2MB + String.fromCharCode(32+~~(Math.random()*96))) let s10MB = "0123456789".repeat(1000*1000); var strings10MB = Array.from(Array(20)).map(o=>s10MB + String.fromCharCode(32+~~(Math.random()*96)))
Tests:
1MB string comparison
const s1 = strings1MB[~~(strings1MB.length*Math.random())]; const s2 = strings1MB[~~(strings1MB.length*Math.random())]; const b = s1 === s2;
2MB string comparison
const s1 = strings2MB[~~(strings2MB.length*Math.random())]; const s2 = strings2MB[~~(strings2MB.length*Math.random())]; const b = s1 === s2;
10MB string comparison
const s1 = strings10MB[~~(strings10MB.length*Math.random())]; const s2 = strings10MB[~~(strings10MB.length*Math.random())]; const b = s1 === s2;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
1MB string comparison
2MB string comparison
10MB string comparison
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
5 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0
Browser/OS:
Chrome 142 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
1MB string comparison
66170.2 Ops/sec
2MB string comparison
10447.4 Ops/sec
10MB string comparison
1238.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.1:latest
, generated one year ago):
Let's dive into the details of this benchmark. **What is being tested?** The benchmark tests the performance of comparing large strings in JavaScript, specifically the `===` operator (equality check). The test cases compare strings of varying lengths: 1MB, 2MB, and 10MB. **What options are compared?** There are no alternative options compared in this benchmark. However, it's likely that other equality operators or string comparison methods could be tested as alternatives. **Pros and cons of the different approaches** In this case, there is only one approach being tested: using the `===` operator to compare strings. This method has both pros and cons: Pros: * Easy to use and understand * Widely supported across browsers and JavaScript engines Cons: * Not optimized for large string comparisons (as shown in this benchmark) **Other considerations** When working with large strings, it's essential to consider the following factors that might impact performance: 1. **String length**: Larger strings can lead to slower comparison times. 2. **Character encoding**: Different character encodings can affect string comparison speeds. 3. **Browser and JavaScript engine optimizations**: Some browsers or engines might optimize their equality operators for large string comparisons. **Library used** No external libraries are used in this benchmark. The tests only rely on standard JavaScript functionality, specifically the `===` operator. **Special JS feature or syntax** None mentioned in this specific benchmark definition. **Other alternatives** Some potential alternative methods to compare strings could be: 1. **Using a library**: A library like Lodash or a custom implementation might provide optimized string comparison functions. 2. **Implementing a custom equality check**: Writing a custom function to compare strings, potentially using algorithms like levenshtein distance or suffix tree matching. These alternatives would require further testing and evaluation to determine their performance benefits compared to the standard `===` operator used in this benchmark.
Related benchmarks:
large string comparison benchmark
Simple string compare vs MurmurHash on a large string
large string comparison1
large string size comparison
Comments
Confirm delete:
Do you really want to delete benchmark?