Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Test463575637
(version: 0)
fer45y55g5
Comparing performance of:
Tererer4 vs ergrtrthryh
Created:
one year ago
by:
Registered User
Jump to the latest result
Tests:
Tererer4
const objects = [ { id: 1, name: "Test 1", object_type: 1 }, { id: 2, name: "Test 2", object_type: 1 }, { id: 3, name: "Test 3", object_type: 2 }, { id: 4, name: "Test 4", object_type: 3 }, ] const object_types = [ { id: 1, class: "Устройства" }, { id: 2, class: "Устройства" }, { id: 3, class: "Порты" }, { id: 4, class: "Кабели" } ] const className = "Устройства"; function result (objects, object_types, className) { const filterObjectForClass = object_types .filter(item => item.class === className) const res = objects .filter(item => { const matchElem = filterObjectForClass.find(elem => elem.id === item.object_type); return matchElem && item.object_type === matchElem.id }) .map(item => item.name) .join() return res; } result(objects,object_types,className);
ergrtrthryh
const objects = [ { id: 1, name: "Test 1", object_type: 1 }, { id: 2, name: "Test 2", object_type: 1 }, { id: 3, name: "Test 3", object_type: 2 }, { id: 4, name: "Test 4", object_type: 3 }, ] const object_types = [ { id: 1, class: "Устройства" }, { id: 2, class: "Устройства" }, { id: 3, class: "Порты" }, { id: 4, class: "Кабели" } ] const className = "Устройства"; function result (objects, object_types, className) { const arr = [] for (let i = 0; i < object_types.length; i++) { if (object_types.class === className) { arr.push(object_types.id) } } const filterObjectForClass = new Set(arr); let result = ''; objects.forEach(item => { if (filterObjectForClass.has(item.object_type)) { result += item.name + ','; } }) return result; } result(objects,object_types,className);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Tererer4
ergrtrthryh
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/126.0.0.0 YaBrowser/24.7.0.0 Safari/537.36
Browser/OS:
Yandex Browser 24 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Tererer4
3004112.2 Ops/sec
ergrtrthryh
3185890.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** MeasureThat.net is a platform for testing and comparing the performance of JavaScript code on different browsers, devices, and operating systems. The provided benchmark definition consists of two test cases: 1. "Tererer4" 2. "ergrtrthryh" Both tests involve filtering an array of objects based on their class name. **Benchmark Definition** The benchmark definition includes the following elements: * **Script Preparation Code**: None (empty string) * **Html Preparation Code**: None (empty string) * **Benchmark Definition**: A JavaScript function that takes three parameters: `objects`, `object_types`, and `className`. The function filters the objects based on their class name and returns a concatenated string of names. **Options Compared** The benchmark compares two different approaches to filtering the objects: 1. **First Approach (Tererer4)**: * Uses the `filter()` method to filter objects based on their class name. * Uses the `map()` method to concatenate the filtered object names into a string. * Returns the concatenated string of object names. 2. **Second Approach (ergrtrthryh)**: * Creates an array of IDs that match the specified class name using a `for` loop. * Converts the array to a Set for efficient lookup. * Iterates through the original objects array and concatenates the names of objects with matching IDs. **Pros and Cons** **First Approach (Tererer4)** Pros: * More concise and readable code * Uses built-in Array methods, which are typically optimized for performance Cons: * May have poor cache locality due to repeated `filter()` calls **Second Approach (ergrtrthryh)** Pros: * Can take advantage of Set operations' efficient lookup and caching * Avoids the overhead of repeated `filter()` calls Cons: * More complex code with a separate array creation step * May have slower startup times due to the additional computation **Other Considerations** * Both approaches have similar execution time profiles, suggesting that the difference in performance is likely due to the specifics of the implementation rather than the underlying algorithm. * The use of `filter()` and `map()` methods in the first approach provides a clear and concise implementation that is easy to understand and maintain. **Alternative Approaches** Other possible approaches could include: * Using a single pass through the objects array with a custom loop or iterator * Utilizing a dedicated library or framework for efficient object filtering (e.g., Lodash) * Implementing a hybrid approach that combines elements of both methods However, these alternatives would likely require significant changes to the benchmark implementation and may not yield substantial performance benefits.
Related benchmarks:
Multiple Nil checks
Multiple Nil checks 0.1
Multiple Nil checks 0.2
Multiple Nil checks 0.3
chain replace
Comments
Confirm delete:
Do you really want to delete benchmark?