Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
loops-perf
(version: 0)
Comparing performance of:
for of vs for in vs for vs while vs forEach() with function vs forEach() with closure vs for, reversed vs for, cached length vs while, reversed vs while, cached length
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script> var arr = new Array(250); var out = new Array(250); </script>
Script Preparation code:
arr.fill(Math.random()); out.length = 0;
Tests:
for of
for (const item of arr) { out.push(item); }
for in
for (const i in arr) { out.push(arr[i]); }
for
for (var i = 0; i < arr.length; ++i) { out.push(arr[i]); }
while
var i = 0; while (i < arr.length) { out.push(arr[i]); i++; }
forEach() with function
arr.forEach(function(x) { out.push(x); });
forEach() with closure
arr.forEach(x => out.push(x));
for, reversed
for (var i = arr.length; i--;) { out.push(arr[i]); }
for, cached length
for (var i = 0, len = arr.length; i < len; ++i) { out.push(arr[i]); }
while, reversed
var i = arr.length; while (i-- > 0) { arr[i]; }
while, cached length
var i = 0; var len = arr.length; while (i < len) { out.push(arr[i]); i++; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (10)
Previous results
Fork
Test case name
Result
for of
for in
for
while
forEach() with function
forEach() with closure
for, reversed
for, cached length
while, reversed
while, cached length
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
gemma2:9b
, generated one year ago):
This looks like a snippet of JSON data representing the results of some performance tests. Here's a breakdown: * **Structure:** It's an array (a list) containing multiple objects. Each object likely represents the results of a single test run. * **Fields:** Each object has several key-value pairs (fields), including: * `"RawUAString"`: This is probably the full user agent string for the browser used in the test. * `"Browser"`: The name and version of the browser, e.g., "Chrome 77". * `"DevicePlatform"`: Indicates the type of device (e.g., "Desktop", "Mobile"). * `"OperatingSystem"`: The operating system used in the test (e.g., "Windows"). * `"ExecutionsPerSecond"`: A numerical value likely representing how many times a specific piece of code was executed per second during the test. * `"TestName"`: The name of the test being performed. **What We Can Infer:** These results seem to be comparing the performance of different JavaScript looping constructs (e.g., "for", "forEach()", "while") across different browser versions and operating systems. Let me know if you have any more specific questions about this data!
Related benchmarks:
lodash test
For vs Min
For vs Min1
Set.has v.s Array.includes
yoooooo
Comments
Confirm delete:
Do you really want to delete benchmark?