Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
spreadArray
(version: 10)
Function that works like a join, but returns array
Comparing performance of:
ComparisonAndConcat vs Concat vs Comparison vs Pop vs Shift vs Slice vs TailSlice vs Slice2 vs For vs ForReverse vs ForComparison vs ForWithInit vs ForEach
Created:
9 years ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var testArray = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); var delim = {'a': 1}; function spreadArrayComparisonAndConcat(array, delim) { return array.reduce(function (result, item, i) { return i === 0 ? result.concat(item) : result.concat(delim, item); }, []); } function spreadArrayConcat(array, delim) { return array.reduce(function (result, item, i) { return result.concat(delim, item); }, []).slice(0, -1); } function spreadArrayComparison(array, delim) { return array.reduce(function (result, item, i) { if (i === 0) { result.push(item); } else { result.push(delim, item); } return result; }, []); } function spreadArrayPop(array, delim) { var r = array.reduce(function (result, item) { result.push(item, delim); return result; }, []); r.pop(); return r; } function spreadArrayShift(array, delim) { var r = array.reduce(function (result, item) { result.push(delim, item); return result; }, []); r.shift(); return r; } function spreadArraySlice(array, delim) { return array.reduce(function (result, item) { result.push(delim, item); return result; }, []).slice(1); } function spreadArrayTailSlice(array, delim) { return array.reduce(function (result, item) { result.push(delim, item); return result; }, []).slice(0, -1); } function spreadArraySlice2(array, delim) { return array.slice(1).reduce(function (result, item) { result.push(delim, item); return result; }, []); } function spreadArrayFor(arr, delim) { var result = []; for (var i = 0; i < arr.length; i++) { result.push(arr[i], delim); }; result.pop(); return result; } function spreadArrayForReverse(arr, delim) { var result = [] for (var i = arr.length - 1; i >= 0; i--) { result.unshift(arr[i], delim); }; result.pop(); return result; } function spreadArrayForComparison(arr, delim) { var result = []; for (var i = 0; i < arr.length; i++) { if (i === 0) { result.push(arr[i]); } else { result.push(delim, arr[i]); } }; return result; } function spreadArrayForWithInit(arr, delim) { var result = [arr[0]] for (var i = 1; i < arr.length; i++) { result.push(delim, arr[i]); }; return result; } function spreadArrayForEach(arr, delim) { var result = []; arr.forEach(function(el, i){ if (i === 0) { result.push(el); } else { result.push(delim, el); } }); return result; }
Tests:
ComparisonAndConcat
spreadArrayComparisonAndConcat(testArray, delim);
Concat
spreadArrayConcat(testArray, delim);
Comparison
spreadArrayComparison(testArray, delim);
Pop
spreadArrayPop(testArray, delim);
Shift
spreadArrayShift(testArray, delim);
Slice
spreadArraySlice(testArray, delim);
TailSlice
spreadArrayTailSlice(testArray, delim);
Slice2
spreadArraySlice2(testArray, delim);
For
spreadArrayFor(testArray, delim);
ForReverse
spreadArrayForReverse(testArray, delim);
ForComparison
spreadArrayForComparison(testArray, delim);
ForWithInit
spreadArrayForWithInit(testArray, delim);
ForEach
spreadArrayForEach(testArray, delim);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (13)
Previous results
Fork
Test case name
Result
ComparisonAndConcat
Concat
Comparison
Pop
Shift
Slice
TailSlice
Slice2
For
ForReverse
ForComparison
ForWithInit
ForEach
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):
I'm ready to dive into the data! It appears that this is a JSON array of test results, specifically for a web browser testing tool. Here's a summary of what I can infer from the data: * There are 8 test cases (or "TestName" values): + Shift + Slice2 + Pop + TailSlice + Slice + ForReverse + ComparisonAndConcat + Concat * Each test case has similar properties: + RawUAString: a string representing the user agent of the browser, including the version and platform information. + Browser: the name of the browser (Yandex Browser 16 in this case). + DevicePlatform: the type of device (Other in this case). + OperatingSystem: the operating system used (Mac OS X 10.11.6 in this case). + ExecutionsPerSecond: a value representing the number of executions per second for each test case. * There is no information on the actual tests being run or any error messages. If you'd like to share more context about what these test results are for, I'd be happy to help interpret them further!
Related benchmarks:
spreadArray
spreadArray
spreadArray
spreadArray
Comments
Confirm delete:
Do you really want to delete benchmark?