Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array pop-push vs last index element check
Comparing pop-push method vs last index check for an array element
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
Browser:
Chrome 123
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
pop-push check
2979303.0 Ops/sec
last-index check
2650433.2 Ops/sec
Script Preparation code:
var arr1 = [0,1,2,3,4,5,6,7,8,9]; var arr2 = []; function pushPopLast(arr, n) { const element = arr.pop(); arr.push(element); return element === n; } function indexLast(arr, n) { const element = arr[arr.lenght - 1]; return element === n; }
Tests:
pop-push check
pushPopLast(arr1, 8); pushPopLast(arr1, 9); pushPopLast(arr2, 9);
last-index check
indexLast(arr1, 8); indexLast(arr1, 9); indexLast(arr2, 9);