Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JS test gareko hai
(version: 0)
asdasd
Comparing performance of:
Array.includes vs OR
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var range = [...Array(10000)].map((_, i) => i); var array = ['a', 'b', 'c', 'd', 'e', 'f']; var value = 'g';
Tests:
Array.includes
const results = []; for (const i in range) { results.push(array.includes(value)); }
OR
const results = []; for (const i in range) { results.push('a' === value || 'b' === value || 'c' === value || 'd' === value || 'e' === value || 'f' === value); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.includes
OR
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Browser/OS:
Firefox 122 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.includes
570.0 Ops/sec
OR
690.4 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'd be happy to explain the provided JSON benchmark definition and its contents. **Benchmark Definition** The benchmark definition is an object that contains metadata about the benchmark, such as its name, description, and preparation code for both the JavaScript script and HTML (which is empty in this case). ```json { "Name": "JS test gareko hai", "Description": "asdasd", "Script Preparation Code": "...", "Html Preparation Code": null } ``` The `Script Preparation Code` contains a snippet of JavaScript code that sets up some variables and data structures, including an array `range` with 10,000 elements, another array `array` containing the string values `'a'` through `'f'`, and a variable `value` set to the string `'g'`. **Individual Test Cases** The benchmark definition also contains multiple test cases, which are represented as arrays of objects. Each test case has two parts: a "Benchmark Definition" that describes how to run the benchmark for each test case, and a "Test Name" that provides a human-readable name for the test case. ```json [ { "Benchmark Definition": "...", "Test Name": "Array.includes" }, { "Benchmark Definition": "...", "Test Name": "OR" } ] ``` The two test cases are: 1. `Array.includes`: This test case iterates over the `range` array and pushes a boolean value indicating whether the string `'g'` is present in the `array` using the `includes()` method. 2. `OR`: This test case iterates over the `range` array and pushes a boolean value indicating whether the string `'g'` matches any of the values in the `array` using OR operations (`||`) between multiple comparisons (`===`). **Benchmark Results** The latest benchmark results are provided as an array of objects, where each object represents a single test run. The fields include: ```json [ { "RawUAString": "...", "Browser": "...", "DevicePlatform": "...", "OperatingSystem": "...", "ExecutionsPerSecond": "...", "TestName": "..." }, ... ] ``` The two test results are: 1. `OR`: This result shows that Firefox 122 on Windows Desktop executed the OR test case at a rate of approximately 569 executions per second. 2. `Array.includes`: This result shows that Firefox 122 on Windows Desktop executed the Array.includes test case at a rate of approximately 690 executions per second. **Library and Special JS Features** Neither of the benchmark definitions uses any external libraries, but it does use some JavaScript syntax features: * The spread operator (`...`) is used to create an array with 10,000 elements in the `Script Preparation Code`. * The template literals (e.g., `const range = [...Array(10000)].map((_, i) => i);`) are used to create a new array in the `Script Preparation Code`. **Alternatives** Other alternatives for benchmarking JavaScript performance could include: 1. Benchmark.js: A popular JavaScript library for building custom benchmarks. 2. JSPerf: A built-in browser feature that allows developers to write and run performance tests. 3. V8 Benchmarks: Official benchmarks provided by the Chrome V8 engine, which can be used as a reference point for comparing performance. Keep in mind that each of these alternatives may have their own strengths and weaknesses, and some might better suit your specific use case than others.
Related benchmarks:
Testing array
testestets 2
JS test gareko hai 2
UINT32Array
Comments
Confirm delete:
Do you really want to delete benchmark?