<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.27.1/ramda.js"></script>
var data = [
1, 2, 3
]
data.map(item => item + 1)
R.map(item => item + 1, data)
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
native add 1 | |
ramda add 1 |
Test name | Executions per second |
---|---|
native add 1 | 34171268.0 Ops/sec |
ramda add 1 | 30792234.0 Ops/sec |
What is being tested?
MeasurThat.net is testing the performance of two approaches: native JavaScript and Ramda (a functional programming library) for mapping over an array.
The benchmark defines a simple script that creates an array data
with some initial values, and then tests the execution speed of two different functions:
map()
method.R.map()
method (from the Ramda library).Options being compared:
The two options being compared are:
map()
method provided by JavaScript engines (e.g., V8 in Chrome).R.map()
function, which provides a functional programming interface for working with arrays.Pros and Cons:
Other considerations:
Benchmark preparation code:
The Script Preparation Code
and Html Preparation Code
sections specify how to include the necessary libraries (Ramda) before running the benchmark. This ensures that the tests are run with a consistent environment and without external dependencies interfering with the results.
In summary, MeasurThat.net is testing the performance difference between using native JavaScript's map()
method versus Ramda's R.map()
function for mapping over an array. The test provides valuable insights into the relative speeds of these two approaches, which can help developers make informed decisions about the best library or approach to use in their projects.