Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
map vs fast map
(version: 0)
Comparing performance of:
regular map vs fast.js map
Created:
5 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://bundle.run/fast.js@0.1.1'></script>
Script Preparation code:
const lim = 100000; let i = 0; var a = []; while (i < lim) { a.push({memb: i}); i++; } function getMemb(av) { return av.memb; }
Tests:
regular map
var b = a.map(getMemb);
fast.js map
var b = fast_js.map(a, getMemb);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
regular map
fast.js map
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
regular map
1501.2 Ops/sec
fast.js map
6649.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark and explain what's being tested, compared options, pros and cons, and other considerations. **Benchmark Overview** The benchmark compares two ways of mapping an array in JavaScript: using the native `map()` function and using a custom implementation provided by the "fast.js" library. **Script Preparation Code** The script preparation code creates an array `a` with 100,000 elements, where each element is an object with a single property `memb`. The purpose of this step is to create a large dataset for testing. ```javascript const lim = 100000; let i = 0; var a = []; while (i < lim) { a.push({ memb: i }); i++; } ``` **Html Preparation Code** The HTML preparation code includes the "fast.js" library, which is used to create the custom mapping implementation. ```javascript <script src='https://bundle.run/fast.js@0.1.1'></script> ``` **Benchmark Test Cases** There are two test cases: 1. **Regular Map**: Uses the native `map()` function. 2. **Fast.js Map**: Uses the "fast.js" library to create a custom mapping implementation. **Comparison** The benchmark compares the performance of these two approaches on a large dataset. **Options Compared** * **Native Map (JavaScript)**: The built-in `map()` function, which iterates over the array and applies the callback function to each element. * **Fast.js Map**: A custom mapping implementation provided by the "fast.js" library, which likely uses a more efficient algorithm or optimized code. **Pros and Cons** * **Native Map (JavaScript)**: + Pros: Easy to use, widely supported, and well-maintained. + Cons: May be slower for large datasets due to the overhead of the `map()` function. * **Fast.js Map**: + Pros: Can potentially be faster than the native `map()` function, especially for very large datasets. + Cons: Requires including an external library, which may introduce additional dependencies. **Library - fast.js** The "fast.js" library is a custom implementation of various JavaScript algorithms and data structures. In this case, it provides a mapping implementation that is likely optimized for performance. The exact algorithm used by the "fast.js" library is not specified in the benchmark definition. **Special JS Feature or Syntax (None)** There are no special JavaScript features or syntaxes being tested in this benchmark. **Other Considerations** * **Benchmarking Framework**: The benchmark uses a web-based framework that allows users to create and run microbenchmarks. This framework likely provides additional features, such as code execution, timing, and statistics analysis. * **Hardware and Software Variability**: The benchmark results are reported for Chrome 74 on Windows desktops, which may not be representative of all possible hardware and software configurations. **Alternatives** Other alternatives for mapping large datasets in JavaScript include: * **Array.prototype.reduce()**: An alternative to `map()` that can be used for reducing arrays. * **Dense Hash Tables**: A data structure that allows for fast lookups and updates, potentially faster than the native `map()` function. * **Custom Iterators**: Writing custom iterators or using third-party libraries like RxJS or Lodash can provide more control over the mapping process.
Related benchmarks:
iterating from a filled object VS iterating from a map
Map vs Array vs Object vs Set add item speed in 50000 iters 2
fill + map vs push
Map vs Object read performance for a 1000 key lookup
new Map vs Array.from vs spread operator
Comments
Confirm delete:
Do you really want to delete benchmark?