Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test map size
(version: 0)
Comparing performance of:
Size 10k vs Size 100k vs Size 1000k
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script> function randomString() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; for( var i=0; i < 20; i++ ) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } var randomKey = []; var randomVals = []; for (var i=0; i < 1001000; i++) { randomKey[i] = randomString(); randomVals[i] = randomString(); } </script>
Script Preparation code:
var map10k = new Map(); var map100k = new Map(); var map1000k = new Map(); for (var i=0; i < 10000; i++) { map10k.set(randomKey[i], randomVals[i]); } for (var i=0; i < 100000; i++) { map100k.set(randomKey[i], randomVals[i]); } for (var i=0; i < 1000000; i++) { map1000k.set(randomKey[i], randomVals[i]); }
Tests:
Size 10k
for (var i=0; i < 1000; i++) { var val = map10k.size; }
Size 100k
for (var i=0; i < 1000; i++) { var val = map100k.size; }
Size 1000k
for (var i=0; i < 1000; i++) { var val = map1000k.size; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Size 10k
Size 100k
Size 1000k
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 benchmark and explain what's being tested, compared, and their pros and cons. **Benchmark Overview** The benchmark is designed to measure the performance of JavaScript Map data structures. It creates three instances of Maps with different sizes (10,000, 100,000, and 1,000,000 entries) and iterates over each one to retrieve the size using the `size` property. The goal is to compare the execution times of these iterations. **Options Compared** The benchmark compares the following options: 1. **Small Map Size (10k)**: A small Map with 10,000 entries. 2. **Medium Map Size (100k)**: A medium-sized Map with 100,000 entries. 3. **Large Map Size (1,000k)**: A large Map with 1,000,000 entries. **Pros and Cons of Each Approach** Each approach has its advantages and disadvantages: * **Small Map Size (10k)**: * Pros: * Faster execution times due to fewer iterations. * Less memory usage compared to larger Maps. * Cons: * May not accurately represent real-world scenarios where data sizes are typically larger. * Limited usefulness for applications that require handling large datasets. * **Medium Map Size (100k)**: * Pros: * Provides a reasonable balance between execution time and memory usage. * Can be useful for applications that need to handle moderately sized datasets. * Cons: * May still result in slower execution times compared to very large Maps. * Still limited by the small size of 100,000 entries. * **Large Map Size (1,000k)**: * Pros: * More representative of real-world scenarios where data sizes can be massive. * Can provide more accurate results for applications that require handling large datasets. * Cons: * Longer execution times due to the larger number of iterations. * Higher memory usage, which may impact system performance. **Library and Purpose** The `Map` object in JavaScript is used here as a data structure to store key-value pairs. It provides efficient methods for adding, removing, and retrieving elements, making it suitable for this type of benchmark. **Special JS Feature or Syntax** This benchmark does not explicitly use any special JavaScript features or syntax beyond the standard `Map` data structure. **Other Alternatives** For benchmarking similar scenarios, other alternatives could be: * Using a different data structure like an object with nested properties. * Employing a custom implementation of a Map-like data structure for improved performance. * Utilizing Web Workers to parallelize computations and measure the impact on execution time. **Benchmark Preparation Code Explanation** The script preparation code generates three instances of Maps with different sizes (10,000, 100,000, and 1,000,000 entries) using nested loops. It populates each Map with random key-value pairs for more realistic behavior. The `randomString` function is used to generate unique keys for the maps. **Individual Test Cases Explanation** Each test case measures the execution time of retrieving the size property from a single iteration over a given-sized Map. The tests are named according to their respective map sizes (10k, 100k, and 1,000k).
Related benchmarks:
Object vs Map
Test map size 2
comparing Map and object
Mappers
Comments
Confirm delete:
Do you really want to delete benchmark?