Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
test underscore contains
(version: 0)
Comparing performance of:
vanilla vs underscore
Created:
2 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/underscore@1.13.6/underscore-umd-min.js"></script> <script type="text/javascript"> var contains = function (array, item) { for (var i = 0; i < array.length; i++) { if (array[i] === item) { return true; } } return false; };</script>
Script Preparation code:
var primes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,97]
Tests:
vanilla
contains(primes, 79);
underscore
_.contains(primes, 79);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
vanilla
underscore
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 benchmark and explain what's being tested. **Benchmark Definition JSON** The provided JSON defines two benchmarks: 1. `test underscore contains`: This benchmark is defined by the `Script Preparation Code` section, which includes a JavaScript snippet that creates an array of prime numbers (`primes`) and a function `contains` that checks if an item is present in the array. 2. The benchmark definition itself refers to another JSON file or resource (not shown) that contains two test cases: * `vanilla`: A vanilla JavaScript implementation of the `contains` function using only standard JavaScript features. * `_underscore`: An implementation using the Underscore.js library, which provides a concise way to implement common functional programming utilities. **Options Compared** The benchmark compares the performance of two implementations: 1. **Vanilla JavaScript**: The implementation without any external libraries or frameworks. This test measures the performance of standard JavaScript features. 2. **Underscore.js**: An implementation that uses the Underscore.js library, which provides a set of reusable functions for common tasks. **Pros and Cons** **Vanilla JavaScript:** Pros: * No external dependencies or overhead * Meets basic JavaScript requirements Cons: * May be slower due to the lack of optimization techniques built into libraries like Underscore.js * Less concise code compared to library-based implementations **Underscore.js:** Pros: * Provides a concise and readable implementation of the `contains` function * Optimized for performance, as it leverages the underlying JavaScript engine's optimizations Cons: * Requires an additional dependency (the Underscore.js library) * May introduce overhead due to the need to load and initialize the library **Other Considerations** The benchmark also measures the device platform (Desktop), operating system (Windows), and browser (Chrome 116) used for each test run. This information can help identify potential hardware or software-related factors that might affect performance. **Library: Underscore.js** Underscore.js is a popular JavaScript library that provides a set of reusable functions for common tasks, such as: * Array manipulation (e.g., `contains`, `filter`, `map`) * Functional programming utilities (e.g., `each`, `invoke`) * String manipulation (e.g., `escape`, `unescape`) The Underscore.js library is designed to provide a concise and expressive way to implement common tasks, making the code more readable and maintainable. **Special JavaScript Feature/Syntax** There are no special JavaScript features or syntax used in this benchmark. The implementation relies on standard JavaScript features, such as variables, functions, arrays, and loops.
Related benchmarks:
Underscore each vs custom while
Underscore each vs while
test js includes and some
JS Tests
Comments
Confirm delete:
Do you really want to delete benchmark?