Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
transrorm template 3
(version: 1)
Comparing performance of:
transform1 vs transform2 vs transform3 vs transform4
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Tests:
transform1
const transform1 = (rowTemplate) => { if (!rowTemplate?.length) { return []; } const rows = rowTemplate.length; const cols = rowTemplate[0].length; const result = []; for (let col = 0; col < cols; col++) { for (let row = 0; row < rows; row++) { result.push(rowTemplate[row][col]); } } return result; }; var t1 = [ ["1", "1", "2", "3", "4", "4"], ["1", "1", "5", "6", "4", "4"] ]; for (var i=0; i < 10000; i++) { transform1(t1); }
transform2
const transform2 = (rowTemplate) => { if (!rowTemplate?.length) { return []; } const rows = rowTemplate.length; const cols = rowTemplate[0].length; const result = new Array(rows * cols); for (let col = 0; col < cols; col++) { for (let row = 0; row < rows; row++) { result.push(rowTemplate[row][col]); } } return result; }; var t1 = [ ["1", "1", "2", "3", "4", "4"], ["1", "1", "5", "6", "4", "4"] ]; for (var i=0; i < 10000; i++) { transform2(t1); }
transform3
const transform3 = (rowTemplate) => { if (!rowTemplate?.length) { return []; } const rows = rowTemplate.length; const cols = rowTemplate[0].length; const result = new Array(rows * cols); for (let col = 0; col < cols; col++) { for (let row = 0; row < rows; row++) { result[col * cols + row] = rowTemplate[row][col]; } } return result; }; var t1 = [ ["1", "1", "2", "3", "4", "4"], ["1", "1", "5", "6", "4", "4"] ]; for (var i=0; i < 10000; i++) { transform3(t1); }
transform4
const transform4 = (rowTemplate) => { if (!rowTemplate?.length) { return []; } const rows = rowTemplate.length; const cols = rowTemplate[0].length; const result = []; for (let col = 0; col < cols; col++) { for (let row = 0; row < rows; row++) { result[col * cols + row] = rowTemplate[row][col]; } } return result; }; var t1 = [ ["1", "1", "2", "3", "4", "4"], ["1", "1", "5", "6", "4", "4"] ]; for (var i=0; i < 10000; i++) { transform4(t1); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
transform1
transform2
transform3
transform4
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/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
transform1
3802.0 Ops/sec
transform2
2807.2 Ops/sec
transform3
2677.6 Ops/sec
transform4
2403.2 Ops/sec
Related benchmarks:
Array creation
Create 2D Array
Create Square 2D Array
Create Square 2D Array Extended
pre fill array
named vs positional arguments v1
named vs positional arguments v2
transrorm template
transrorm template 2
Comments
Confirm delete:
Do you really want to delete benchmark?