Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map-array-object-get-set
(version: 0)
Comparing performance of:
map vs array vs object
Created:
7 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var map = new Map(); var arr = []; var obj = {}; var key; var randomU32 = function() { return Math.random() * (1 << 31) >>> 0; }
Tests:
map
key = randomU32(); map.set(key, true); key = map.get(key);
array
key = randomU32(); arr[key] = true; key = arr[key];
object
key = randomU32(); obj[key] = true; key = obj[key];
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
map
array
object
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/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
map
2196438.5 Ops/sec
array
2188584.2 Ops/sec
object
2232933.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The provided JSON represents a JavaScript benchmark test case on MeasureThat.net. The test measures the performance of three different data structures: arrays, objects, and Maps. **Script Preparation Code** The script preparation code sets up the necessary variables for the benchmark: * `map`: an empty Map object * `arr` and `obj`: empty arrays and objects respectively * `key`: a random 32-bit unsigned integer generated by the `randomU32` function * `randomU32`: a helper function that returns a pseudo-random 32-bit unsigned integer **Html Preparation Code** There is no HTML preparation code provided, which means that the test likely does not require any HTML elements to be rendered or manipulated. **Individual Test Cases** The benchmark consists of three individual test cases: * **map**: tests the Map data structure * The `Benchmark Definition` code: sets a random key in the map and then retrieves its value. * This test case likely measures the performance of setting and getting values from a Map object. * **array**: tests the array data structure * The `Benchmark Definition` code: sets a random key in an array, assigns a value to it, and then retrieves its value. * This test case likely measures the performance of setting and getting values from an array using indexing. * **object**: tests the object data structure * The `Benchmark Definition` code: sets a random key in an object, assigns a value to it, and then retrieves its value. * This test case likely measures the performance of setting and getting values from an object using property access. **Library Usage** There is no explicit library usage mentioned in the provided JSON. However, JavaScript's built-in `Map` data structure uses the ECMAScript standard library (ECMAScript 2015) to implement its functionality. **Special JS Feature or Syntax** The test case does not explicitly use any special JavaScript features or syntax. The use of `>>> 0` in the `randomU32` function is a common pattern for generating pseudo-random numbers, but it's not specific to any particular feature or syntax. **Other Alternatives** Alternatives to testing array, object, and Map data structures using MeasureThat.net include: * **V8 Perftools**: a tool provided by Google that allows you to benchmark JavaScript performance in different scenarios. * **JSPerf**: a web-based platform for running JavaScript benchmarks and comparing the results across different browsers and versions. * **Benchmark.js**: a lightweight library for creating and running JavaScript benchmarks, including support for various data structures like arrays, objects, and Maps. In summary, MeasureThat.net provides a convenient way to benchmark JavaScript performance for array, object, and Map data structures. By understanding how the test is structured and what it's measuring, you can get insights into the performance characteristics of different data structures in your codebase.
Related benchmarks:
Map vs Array vs Object set uint32 key speed
Map vs Array vs Object has uint32 key speed
Map vs Array vs Object set uint32 key speed11
Object keys vs Array map v2
Map vs Array vs Object set uint32 key speed2
Comments
Confirm delete:
Do you really want to delete benchmark?