Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
find vs foreach large
(version: 0)
Comparing performance of:
forEach vs find
Created:
6 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const numbersArray = [32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 14, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 17, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 16, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35];
Tests:
forEach
const numbersArray = [32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 14, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 17, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 16, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35]; numbersArray.forEach(element => { if(element < 18){ return element; }; });
find
const numbersArray = [32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 14, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 17, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35, 32, 21, 22, 28, 16, 26, 31, 30, 27, 28, 33, 33, 34, 25, 35]; numbersArray.find(element => { element < 18; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
forEach
find
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):
A benchmarking result! Let's analyze the data: **Find operation:** * Browser: Chrome 114 * DevicePlatform: Desktop * OperatingSystem: Windows * ExecutionsPerSecond: 13037595.0 * TestName: find This means that on a desktop device with Windows operating system and running Chrome 114, the `find` operation executed approximately 13 million times per second. **ForEach operation:** * Browser: Chrome 114 * DevicePlatform: Desktop * OperatingSystem: Windows * ExecutionsPerSecond: 13788940.0 * TestName: forEach This means that on a desktop device with Windows operating system and running Chrome 114, the `forEach` operation executed approximately 13.7 million times per second. Comparing the two results, we can see that: 1. The `forEach` operation is about 5% faster than the `find` operation. 2. The `forEach` operation uses more CPU resources (executions per second) due to its iterative nature, while the `find` operation likely uses a more optimized algorithm. Keep in mind that these results are specific to this Chrome version and device configuration.
Related benchmarks:
forEach vs map 4
forEach vs map large array
forEach vs map logged
Array.from(new Set(array)) vs [...new Set(array)]
Comments
Confirm delete:
Do you really want to delete benchmark?